Skip to content

Commit 5f0bd16

Browse files
committed
feature: add log for git cherry-pick/rebase/revert/merge --continue/--skip/--abort (#2096)
1 parent 52281a4 commit 5f0bd16

File tree

2 files changed

+32
-9
lines changed

2 files changed

+32
-9
lines changed

src/ViewModels/InProgressContexts.cs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,28 @@ namespace SourceGit.ViewModels
55
{
66
public abstract class InProgressContext
77
{
8-
public async Task ContinueAsync()
8+
public string Name
9+
{
10+
get;
11+
protected set;
12+
}
13+
14+
public async Task ContinueAsync(CommandLog log)
915
{
1016
if (_continueCmd != null)
11-
await _continueCmd.ExecAsync();
17+
await _continueCmd.Use(log).ExecAsync();
1218
}
1319

14-
public async Task SkipAsync()
20+
public async Task SkipAsync(CommandLog log)
1521
{
1622
if (_skipCmd != null)
17-
await _skipCmd.ExecAsync();
23+
await _skipCmd.Use(log).ExecAsync();
1824
}
1925

20-
public async Task AbortAsync()
26+
public async Task AbortAsync(CommandLog log)
2127
{
2228
if (_abortCmd != null)
23-
await _abortCmd.ExecAsync();
29+
await _abortCmd.Use(log).ExecAsync();
2430
}
2531

2632
protected Commands.Command _continueCmd = null;
@@ -42,6 +48,8 @@ public string HeadName
4248

4349
public CherryPickInProgress(Repository repo)
4450
{
51+
Name = "Cherry-Pick";
52+
4553
_continueCmd = new Commands.Command
4654
{
4755
WorkingDirectory = repo.FullPath,
@@ -93,6 +101,8 @@ public Models.Commit Onto
93101

94102
public RebaseInProgress(Repository repo)
95103
{
104+
Name = "Rebase";
105+
96106
_continueCmd = new Commands.Command
97107
{
98108
WorkingDirectory = repo.FullPath,
@@ -144,6 +154,8 @@ public Models.Commit Head
144154

145155
public RevertInProgress(Repository repo)
146156
{
157+
Name = "Revert";
158+
147159
_continueCmd = new Commands.Command
148160
{
149161
WorkingDirectory = repo.FullPath,
@@ -189,6 +201,8 @@ public string SourceName
189201

190202
public MergeInProgress(Repository repo)
191203
{
204+
Name = "Merge";
205+
192206
_continueCmd = new Commands.Command
193207
{
194208
WorkingDirectory = repo.FullPath,

src/ViewModels/WorkingCopy.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ public async Task ContinueMergeAsync()
541541
if (File.Exists(mergeMsgFile) && !string.IsNullOrWhiteSpace(_commitMessage))
542542
await File.WriteAllTextAsync(mergeMsgFile, _commitMessage);
543543

544-
await _inProgressContext.ContinueAsync();
544+
var log = _repo.CreateLog($"Continue {_inProgressContext.Name}");
545+
await _inProgressContext.ContinueAsync(log);
546+
log.Complete();
547+
545548
CommitMessage = string.Empty;
546549
IsCommitting = false;
547550
}
@@ -558,7 +561,10 @@ public async Task SkipMergeAsync()
558561
using var lockWatcher = _repo.LockWatcher();
559562
IsCommitting = true;
560563

561-
await _inProgressContext.SkipAsync();
564+
var log = _repo.CreateLog($"Skip {_inProgressContext.Name}");
565+
await _inProgressContext.SkipAsync(log);
566+
log.Complete();
567+
562568
CommitMessage = string.Empty;
563569
IsCommitting = false;
564570
}
@@ -575,7 +581,10 @@ public async Task AbortMergeAsync()
575581
using var lockWatcher = _repo.LockWatcher();
576582
IsCommitting = true;
577583

578-
await _inProgressContext.AbortAsync();
584+
var log = _repo.CreateLog($"Abort {_inProgressContext.Name}");
585+
await _inProgressContext.AbortAsync(log);
586+
log.Complete();
587+
579588
CommitMessage = string.Empty;
580589
IsCommitting = false;
581590
}

0 commit comments

Comments
 (0)