Repository navigation
Expand file tree
/
Copy pathStashChanges.cs
More file actions
72 lines (62 loc) · 1.86 KB
/
Copy pathStashChanges.cs
File metadata and controls
72 lines (62 loc) · 1.86 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
63
64
65
66
67
68
69
70
71
72
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class StashChanges : Popup
{
public string Message
{
get;
set;
}
public bool CanIgnoreUntracked
{
get;
private set;
}
public bool IncludeUntracked
{
get;
set;
}
public StashChanges(Repository repo, List<Models.Change> changes, bool canIgnoreUntracked)
{
_repo = repo;
_changes = changes;
CanIgnoreUntracked = canIgnoreUntracked;
IncludeUntracked = true;
View = new Views.StashChanges() { DataContext = this };
}
public override Task<bool> Sure()
{
var jobs = _changes;
if (CanIgnoreUntracked && !IncludeUntracked)
{
jobs = new List<Models.Change>();
foreach (var job in _changes)
{
if (job.WorkTree != Models.ChangeState.Untracked && job.WorkTree != Models.ChangeState.Added)
{
jobs.Add(job);
}
}
}
if (jobs.Count == 0)
return null;
_repo.SetWatcherEnabled(false);
ProgressDescription = $"Stash changes ...";
return Task.Run(() =>
{
new Commands.Stash(_repo.FullPath).Push(jobs, Message);
CallUIThread(() =>
{
_repo.MarkWorkingCopyDirtyManually();
_repo.SetWatcherEnabled(true);
});
return true;
});
}
private readonly Repository _repo = null;
private readonly List<Models.Change> _changes = null;
}
}