Repository navigation
Expand file tree
/
Copy pathDiscard.cs
More file actions
62 lines (51 loc) · 1.63 KB
/
Copy pathDiscard.cs
File metadata and controls
62 lines (51 loc) · 1.63 KB
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
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class Discard : Popup
{
public object Mode
{
get;
private set;
}
public Discard(Repository repo)
{
_repo = repo;
Mode = new Models.Null();
View = new Views.Discard { DataContext = this };
}
public Discard(Repository repo, List<Models.Change> changes)
{
_repo = repo;
_changes = changes;
if (_changes == null)
Mode = new Models.Null();
else if (_changes.Count == 1)
Mode = _changes[0].Path;
else
Mode = _changes.Count;
View = new Views.Discard() { DataContext = this };
}
public override Task<bool> Sure()
{
_repo.SetWatcherEnabled(false);
ProgressDescription = _changes == null ? "Discard all local changes ..." : $"Discard total {_changes.Count} changes ...";
return Task.Run(() =>
{
if (_changes == null)
Commands.Discard.All(_repo.FullPath);
else
Commands.Discard.Changes(_repo.FullPath, _changes);
CallUIThread(() =>
{
_repo.MarkWorkingCopyDirtyManually();
_repo.SetWatcherEnabled(true);
});
return true;
});
}
private readonly Repository _repo = null;
private readonly List<Models.Change> _changes = null;
}
}