-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathUpdateSubmodules.cs
86 lines (71 loc) · 1.95 KB
/
UpdateSubmodules.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class UpdateSubmodules : Popup
{
public List<string> Submodules
{
get;
} = [];
public string SelectedSubmodule
{
get;
set;
}
public bool UpdateAll
{
get => _updateAll;
set => SetProperty(ref _updateAll, value);
}
public bool EnableInit
{
get;
set;
} = true;
public bool EnableRecursive
{
get;
set;
} = true;
public bool EnableRemote
{
get;
set;
} = false;
public UpdateSubmodules(Repository repo)
{
_repo = repo;
foreach (var submodule in _repo.Submodules)
Submodules.Add(submodule.Path);
SelectedSubmodule = Submodules.Count > 0 ? Submodules[0] : string.Empty;
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
List<string> targets;
if (_updateAll)
targets = Submodules;
else
targets = [SelectedSubmodule];
var log = _repo.CreateLog("Update Submodule");
Use(log);
return Task.Run(() =>
{
foreach (var submodule in targets)
{
new Commands.Submodule(_repo.FullPath).Use(log).Update(
submodule,
EnableInit,
EnableRecursive,
EnableRemote);
}
log.Complete();
CallUIThread(() => _repo.SetWatcherEnabled(true));
return true;
});
}
private readonly Repository _repo = null;
private bool _updateAll = true;
}
}