enhance: save commit message to .git/MERGE_MSG while closing repo with in-progress state (#1795)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-10-24 10:23:36 +08:00
parent 5c75bb86bb
commit 81f622b4b1
2 changed files with 7 additions and 8 deletions

View File

@@ -567,7 +567,11 @@ namespace SourceGit.ViewModels
if (!_isWorktree)
{
_settings.LastCommitMessage = _workingCopy.CommitMessage;
if (_workingCopy.InProgressContext != null && !string.IsNullOrEmpty(_workingCopy.CommitMessage))
File.WriteAllText(Path.Combine(GitDir, "MERGE_MSG"), _workingCopy.CommitMessage);
else
_settings.LastCommitMessage = _workingCopy.CommitMessage;
using var stream = File.Create(Path.Combine(_gitCommonDir, "sourcegit.settings"));
JsonSerializer.Serialize(stream, _settings, JsonCodeGen.Default.RepositorySettings);
}

View File

@@ -796,13 +796,8 @@ namespace SourceGit.ViewModels
if (LoadCommitMessageFromFile(Path.Combine(_repo.GitDir, "rebase-merge", "message")))
break;
var rebaseProcessingFile = Path.Combine(_repo.GitDir, "rebase-apply", "final-commit");
if (File.Exists(rebaseProcessingFile))
{
var sha = File.ReadAllText(rebaseProcessingFile);
if (!string.IsNullOrEmpty(sha))
CommitMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, sha).GetResult();
}
if (_inProgressContext is RebaseInProgress { StoppedAt: { } stopAt })
CommitMessage = new Commands.QueryCommitFullMessage(_repo.FullPath, stopAt.SHA).GetResult();
} while (false);
}