-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathInit.cs
56 lines (47 loc) · 1.5 KB
/
Init.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
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class Init : Popup
{
public string TargetPath
{
get => _targetPath;
set => SetProperty(ref _targetPath, value);
}
public string Reason
{
get;
private set;
}
public Init(string pageId, string path, RepositoryNode parent, string reason)
{
_pageId = pageId;
_targetPath = path;
_parentNode = parent;
Reason = string.IsNullOrEmpty(reason) ? "Invalid repository detected!" : reason;
}
public override Task<bool> Sure()
{
ProgressDescription = $"Initialize git repository at: '{_targetPath}'";
var log = new CommandLog("Initialize");
Use(log);
return Task.Run(() =>
{
var succ = new Commands.Init(_pageId, _targetPath).Use(log).Exec();
log.Complete();
if (succ)
{
CallUIThread(() =>
{
Preferences.Instance.FindOrAddNodeByRepositoryPath(_targetPath, _parentNode, true);
Welcome.Instance.Refresh();
});
}
return succ;
});
}
private readonly string _pageId = null;
private string _targetPath = null;
private readonly RepositoryNode _parentNode = null;
}
}