Skip to content

Commit 823bde3

Browse files
committed
enhance: generate a better commit message manually when cherry-picking multiple commits with -n -x (sourcegit-scm#2295)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 44103f9 commit 823bde3

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/ViewModels/CherryPick.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Text;
24
using System.Threading.Tasks;
35

46
namespace SourceGit.ViewModels
@@ -93,6 +95,19 @@ public override async Task<bool> Sure()
9395
string.Empty)
9496
.Use(log)
9597
.ExecAsync();
98+
99+
if (!AutoCommit && Targets.Count > 1)
100+
{
101+
var builder = new StringBuilder();
102+
foreach (var t in Targets)
103+
builder.Append(t.Subject).Append("\n");
104+
105+
builder.Append("\n");
106+
foreach (var t in Targets)
107+
builder.Append("(cherry picked from commit ").Append(t.SHA).Append(")\n");
108+
109+
File.WriteAllText(Path.Combine(_repo.GitDir, "MERGE_MSG"), builder.ToString());
110+
}
96111
}
97112

98113
log.Complete();

0 commit comments

Comments
 (0)