-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy pathCherryPick.cs
More file actions
104 lines (91 loc) · 2.55 KB
/
CherryPick.cs
File metadata and controls
104 lines (91 loc) · 2.55 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
using System.Collections.Generic;
using System.Threading.Tasks;
namespace SourceGit.ViewModels
{
public class CherryPick : Popup
{
public List<Models.Commit> Targets
{
get;
private set;
}
public bool IsMergeCommit
{
get;
private set;
}
public List<Models.Commit> ParentsForMergeCommit
{
get;
private set;
}
public int MainlineForMergeCommit
{
get;
set;
}
public bool AppendSourceToMessage
{
get;
set;
}
public bool AutoCommit
{
get;
set;
}
public CherryPick(Repository repo, List<Models.Commit> targets)
{
_repo = repo;
Targets = targets;
IsMergeCommit = false;
ParentsForMergeCommit = [];
MainlineForMergeCommit = 0;
AppendSourceToMessage = true;
AutoCommit = true;
}
public CherryPick(Repository repo, Models.Commit merge, List<Models.Commit> parents)
{
_repo = repo;
Targets = [merge];
IsMergeCommit = true;
ParentsForMergeCommit = parents;
MainlineForMergeCommit = 0;
AppendSourceToMessage = true;
AutoCommit = true;
}
public override async Task<bool> Sure()
{
using var lockWatcher = _repo.LockWatcher();
_repo.ClearCommitMessage();
ProgressDescription = "Cherry-Pick commit(s) ...";
var log = _repo.CreateLog("Cherry-Pick");
Use(log);
if (IsMergeCommit)
{
await new Commands.CherryPick(
_repo.FullPath,
Targets[0].SHA,
!AutoCommit,
AppendSourceToMessage,
$"-m {MainlineForMergeCommit + 1}")
.Use(log)
.ExecAsync();
}
else
{
await new Commands.CherryPick(
_repo.FullPath,
string.Join(' ', Targets.ConvertAll(c => c.SHA)),
!AutoCommit,
AppendSourceToMessage,
string.Empty)
.Use(log)
.ExecAsync();
}
log.Complete();
return true;
}
private readonly Repository _repo = null;
}
}