Skip to content

Commit cc5a146

Browse files
committed
enhance: squashing head will generate default new commit message automatically
Signed-off-by: leo <longshuang@msn.cn>
1 parent 44286e8 commit cc5a146

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/ViewModels/Histories.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.IO;
5+
using System.Text;
56
using System.Threading.Tasks;
67

78
using Avalonia.Controls;
@@ -325,10 +326,18 @@ public async Task SquashHeadAsync(Models.Commit head)
325326
{
326327
if (head.Parents.Count == 1)
327328
{
328-
var message = await new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).GetResultAsync();
329-
var parent = _commits.Find(x => x.SHA.Equals(head.Parents[0]));
330-
if (parent != null && _repo.CanCreatePopup())
331-
_repo.ShowPopup(new Squash(_repo, parent, message));
329+
var parent = await new Commands.QuerySingleCommit(_repo.FullPath, head.Parents[0]).GetResultAsync();
330+
if (parent == null)
331+
return;
332+
333+
var headMessage = await new Commands.QueryCommitFullMessage(_repo.FullPath, head.SHA).GetResultAsync();
334+
var parentMessage = await new Commands.QueryCommitFullMessage(_repo.FullPath, head.Parents[0]).GetResultAsync();
335+
336+
var builder = new StringBuilder();
337+
builder.Append(parentMessage).Append("\n\n").Append(headMessage);
338+
339+
if (_repo.CanCreatePopup())
340+
_repo.ShowPopup(new Squash(_repo, parent, builder.ToString()));
332341
}
333342
}
334343

0 commit comments

Comments
 (0)