From 82f125d435dc966b877c8bf63eb1ecdd882fc627 Mon Sep 17 00:00:00 2001 From: Michael Seibt Date: Sun, 5 May 2019 19:28:37 +0200 Subject: [PATCH] Store the commit message in the correct file and Replace commit message in an undo-able way Disable change of message and amend unless Normal --- GitCommands/CommitHelper.cs | 77 ----- GitCommands/CommitMessageManager.cs | 124 ++++++++ GitCommands/Git/GitModule.cs | 10 - GitCommands/GitCommands.csproj | 2 +- GitUI/CommandsDialogs/FormCommit.cs | 72 +++-- GitUI/SpellChecker/EditNetSpell.cs | 7 +- .../CommitMessageManagerTests.cs | 273 ++++++++++++++++++ .../GitCommandsTests/GitCommandsTests.csproj | 1 + .../CommandsDialogs/ReferenceRepository.cs | 2 +- 9 files changed, 447 insertions(+), 121 deletions(-) delete mode 100644 GitCommands/CommitHelper.cs create mode 100644 GitCommands/CommitMessageManager.cs create mode 100644 UnitTests/GitCommandsTests/CommitMessageManagerTests.cs diff --git a/GitCommands/CommitHelper.cs b/GitCommands/CommitHelper.cs deleted file mode 100644 index 82285956381..00000000000 --- a/GitCommands/CommitHelper.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System.IO; - -namespace GitCommands -{ - public static class CommitHelper - { - public static void SetCommitMessage(GitModule module, string commitMessageText, bool amendCommit) - { - if (string.IsNullOrEmpty(commitMessageText)) - { - File.Delete(GetCommitMessagePath(module)); - File.Delete(GetAmendPath(module)); - return; - } - - using (var textWriter = new StreamWriter(GetCommitMessagePath(module), false, module.CommitEncoding)) - { - textWriter.Write(commitMessageText); - } - - if (AppSettings.RememberAmendCommitState && amendCommit) - { - File.WriteAllText(GetAmendPath(module), true.ToString()); - } - else if (File.Exists(GetAmendPath(module))) - { - File.Delete(GetAmendPath(module)); - } - } - - public static string GetCommitMessage(GitModule module) - { - if (File.Exists(GetCommitMessagePath(module))) - { - return File.ReadAllText(GetCommitMessagePath(module), module.CommitEncoding); - } - - return string.Empty; - } - - public static string GetCommitMessagePath(GitModule module) - { - return GetFilePath(module, "COMMITMESSAGE"); - } - - private static string GetAmendPath(GitModule module) - { - return GetFilePath(module, "GitExtensions.amend"); - } - - private static string GetFilePath(GitModule module, string action) - { - return Path.Combine(module.WorkingDirGitDir, action); - } - - public static bool GetAmendState(GitModule module) - { - bool amendState = false; - - if (AppSettings.RememberAmendCommitState && File.Exists(GetAmendPath(module))) - { - var amendSaveStateFilePath = GetAmendPath(module); - bool.TryParse(File.ReadAllText(amendSaveStateFilePath), out amendState); - try - { - File.Delete(amendSaveStateFilePath); - } - catch - { - // ignore - } - } - - return amendState; - } - } -} \ No newline at end of file diff --git a/GitCommands/CommitMessageManager.cs b/GitCommands/CommitMessageManager.cs new file mode 100644 index 00000000000..d999fa3d9b2 --- /dev/null +++ b/GitCommands/CommitMessageManager.cs @@ -0,0 +1,124 @@ +using System.IO.Abstractions; +using System.Text; + +namespace GitCommands +{ + public interface ICommitMessageManager + { + /// + /// Reads/stores whether the previous commit shall be amended (if AppSettings.RememberAmendCommitState). + /// + bool AmendState { get; set; } + + /// + /// The pathname of the file where a prepared (non-merge) commit message is stored. + /// + string CommitMessagePath { get; } + + /// + /// Returns whether .git/MERGE_MSG exists. + /// + bool IsMergeCommit { get; } + + /// + /// Reads/stores the prepared commit message from/in .git/MERGE_MSG if it exists or else in .git/COMMITMESSAGE. + /// + string MergeOrCommitMessage { get; set; } + + /// + /// Deletes .git/COMMITMESSAGE and the file with the AmendState. + /// + void ResetCommitMessage(); + } + + public sealed class CommitMessageManager : ICommitMessageManager + { + private readonly string _amendSaveStatePath; + private readonly string _commitMessagePath; + private readonly string _mergeMessagePath; + + private Encoding _commitEncoding; + private IFileSystem _fileSystem; + + public CommitMessageManager(string workingDirGitDir, Encoding commitEncoding) + : this(workingDirGitDir, commitEncoding, new FileSystem()) + { + } + + private CommitMessageManager(string workingDirGitDir, Encoding commitEncoding, IFileSystem fileSystem) + { + _fileSystem = fileSystem; + _commitEncoding = commitEncoding; + _amendSaveStatePath = GetFilePath(workingDirGitDir, "GitExtensions.amend"); + _commitMessagePath = GetFilePath(workingDirGitDir, "COMMITMESSAGE"); + _mergeMessagePath = GetFilePath(workingDirGitDir, "MERGE_MSG"); + } + + public bool AmendState + { + get + { + bool amendState = false; + + if (AppSettings.RememberAmendCommitState && _fileSystem.File.Exists(_amendSaveStatePath)) + { + bool.TryParse(_fileSystem.File.ReadAllText(_amendSaveStatePath), out amendState); + } + + return amendState; + } + set + { + if (AppSettings.RememberAmendCommitState && value) + { + _fileSystem.File.WriteAllText(_amendSaveStatePath, true.ToString()); + } + else + { + _fileSystem.File.Delete(_amendSaveStatePath); + } + } + } + + public string CommitMessagePath => _commitMessagePath; + + public bool IsMergeCommit => _fileSystem.File.Exists(_mergeMessagePath); + + public string MergeOrCommitMessage + { + get + { + var (file, exists) = GetMergeOrCommitMessagePath(); + return exists ? _fileSystem.File.ReadAllText(file, _commitEncoding) : string.Empty; + } + set + { + _fileSystem.File.WriteAllText(GetMergeOrCommitMessagePath().FilePath, value ?? string.Empty, _commitEncoding); + } + } + + public void ResetCommitMessage() + { + _fileSystem.File.Delete(_commitMessagePath); + _fileSystem.File.Delete(_amendSaveStatePath); + } + + private string GetFilePath(string workingDirGitDir, string fileName) => _fileSystem.Path.Combine(workingDirGitDir, fileName); + + private (string FilePath, bool FileExists) GetMergeOrCommitMessagePath() + { + if (IsMergeCommit) + { + return (_mergeMessagePath, FileExists: true); + } + + return (_commitMessagePath, _fileSystem.File.Exists(_commitMessagePath)); + } + + internal class TestAccessor + { + internal static CommitMessageManager Construct(string workingDirGitDir, Encoding commitEncoding, IFileSystem fileSystem) + => new CommitMessageManager(workingDirGitDir, commitEncoding, fileSystem); + } + } +} \ No newline at end of file diff --git a/GitCommands/Git/GitModule.cs b/GitCommands/Git/GitModule.cs index ce358093459..5ea99b9b345 100644 --- a/GitCommands/Git/GitModule.cs +++ b/GitCommands/Git/GitModule.cs @@ -868,16 +868,6 @@ public string GetCommitCountString(string from, string to) (added > 0 ? ("+" + added) : ""); } - public string GetMergeMessage() - { - var file = GetGitDirectory() + "MERGE_MSG"; - - return - File.Exists(file) - ? File.ReadAllText(file) - : ""; - } - public void RunGitK() { if (EnvUtils.RunningOnUnix()) diff --git a/GitCommands/GitCommands.csproj b/GitCommands/GitCommands.csproj index d3986fa1ca3..b838638c0f0 100644 --- a/GitCommands/GitCommands.csproj +++ b/GitCommands/GitCommands.csproj @@ -182,7 +182,7 @@ - + diff --git a/GitUI/CommandsDialogs/FormCommit.cs b/GitUI/CommandsDialogs/FormCommit.cs index 15421b7e7ba..e6b6ddd7421 100644 --- a/GitUI/CommandsDialogs/FormCommit.cs +++ b/GitUI/CommandsDialogs/FormCommit.cs @@ -164,6 +164,7 @@ public sealed partial class FormCommit : GitModuleForm private bool _skipUpdate; private GitItemStatus _currentItem; private bool _currentItemStaged; + private ICommitMessageManager _commitMessageManager; private string _commitTemplate; private bool _isMergeCommit; private bool _shouldRescanChanges = true; @@ -194,6 +195,8 @@ public FormCommit([NotNull] GitUICommands commands, CommitKind commitKind = Comm splitRight.Panel2MinSize = DpiUtil.Scale(100); + _commitMessageManager = new CommitMessageManager(Module.WorkingDirGitDir, Module.CommitEncoding); + Message.TextChanged += Message_TextChanged; Message.TextAssigned += Message_TextAssigned; Message.AddAutoCompleteProvider(new CommitAutoCompleteProvider(Module)); @@ -334,10 +337,14 @@ void AddToSelectionFilter() void ConfigureMessageBox() { - Message.Enabled = _useFormCommitMessage; + Amend.Enabled = _commitKind == CommitKind.Normal; + + bool messageCanBeChanged = _useFormCommitMessage && _commitKind == CommitKind.Normal; + + Message.Enabled = messageCanBeChanged; - commitMessageToolStripMenuItem.Enabled = _useFormCommitMessage; - commitTemplatesToolStripMenuItem.Enabled = _useFormCommitMessage; + commitMessageToolStripMenuItem.Enabled = messageCanBeChanged; + commitTemplatesToolStripMenuItem.Enabled = messageCanBeChanged; Message.WatermarkText = _useFormCommitMessage ? _enterCommitMessageHint.Text @@ -397,7 +404,8 @@ protected override void OnFormClosing(FormClosingEventArgs e) // a special meaning, and can be dangerous if used inappropriately. if (_commitKind == CommitKind.Normal) { - CommitHelper.SetCommitMessage(Module, Message.Text, Amend.Checked); + _commitMessageManager.MergeOrCommitMessage = Message.Text; + _commitMessageManager.AmendState = Amend.Checked; } _splitterManager.SaveSplitters(); @@ -432,20 +440,14 @@ protected override void OnShown(EventArgs e) message = TryAddPrefix("squash!", _editedCommit.Subject); break; default: - message = Module.GetMergeMessage(); - - if (string.IsNullOrEmpty(message)) - { - message = CommitHelper.GetCommitMessage(Module); - Amend.Checked = CommitHelper.GetAmendState(Module); - } - + message = _commitMessageManager.MergeOrCommitMessage; + Amend.Checked = !_commitMessageManager.IsMergeCommit && _commitMessageManager.AmendState; break; } if (_useFormCommitMessage && !string.IsNullOrEmpty(message)) { - Message.Text = message; + Message.Text = message; // initial assignment } else { @@ -479,7 +481,7 @@ void AssignCommitMessageFromTemplate() _templateLoadErrorCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } - Message.Text = text; + Message.Text = text; // initial assignment _commitTemplate = text; } } @@ -601,14 +603,7 @@ private bool AddSelectionToCommitMessage() int selectionStart = Message.SelectionStart; - if (Message.Text.IsNullOrEmpty()) - { - Message.Text = selectedText; - } - else - { - Message.SelectedText = selectedText; - } + Message.SelectedText = selectedText; Message.SelectionStart = selectionStart + selectedText.Length; @@ -1084,7 +1079,7 @@ private void LoadUnstagedOutput(IReadOnlyList allChangedFiles) LoadingStaged.Visible = false; Commit.Enabled = true; CommitAndPush.Enabled = true; - Amend.Enabled = true; + Amend.Enabled = _commitKind == CommitKind.Normal; Reset.Enabled = doChangesExist; EnableStageButtons(true); @@ -1387,8 +1382,8 @@ void DoCommit() ScriptManager.RunEventScripts(this, ScriptEvent.AfterCommit); - Message.Text = string.Empty; - CommitHelper.SetCommitMessage(Module, string.Empty, Amend.Checked); + Message.Text = string.Empty; // Message.Text has been used and stored + _commitMessageManager.ResetCommitMessage(); bool pushCompleted = true; if (push) @@ -1428,6 +1423,8 @@ void DoCommit() MessageBox.Show(this, $"Exception: {e.Message}"); } + return; + bool IsCommitMessageValid() { if (AppSettings.CommitValidationMaxCntCharsFirstLine > 0) @@ -1484,6 +1481,19 @@ bool IsCommitMessageValid() } } + /// + /// replace the Message.Text in an undo-able way + /// + /// the new message + private void ReplaceMessage(string message) + { + if (Message.Text != message) + { + Message.SelectAll(); + Message.SelectedText = message; + } + } + private void RescanChanges() { if (_shouldRescanChanges) @@ -1967,7 +1977,7 @@ void ProcessStart(FormStatus form) EnableStageButtons(true); Commit.Enabled = true; - Amend.Enabled = true; + Amend.Enabled = _commitKind == CommitKind.Normal; } if (AppSettings.RevisionGraphShowWorkingDirChanges) @@ -2180,7 +2190,7 @@ private void SetCommitMessageFromTextBox(string commitMessageText) // Save last commit message in settings. This way it can be used in multiple repositories. AppSettings.LastCommitMessage = commitMessageText; - var path = CommitHelper.GetCommitMessagePath(Module); + var path = _commitMessageManager.CommitMessagePath; // Commit messages are UTF-8 by default unless otherwise in the config file. // The git manual states: @@ -2322,7 +2332,7 @@ private void CommitMessageToolStripMenuItemDropDownItemClicked(object sender, To { if (e.ClickedItem.Tag != null) { - Message.Text = ((string)e.ClickedItem.Tag).Trim(); + ReplaceMessage(((string)e.ClickedItem.Tag).Trim()); } } @@ -2391,7 +2401,7 @@ private void generateListOfChangesInSubmodulesChangesToolStripMenuItem_Click(obj } } - Message.Text = sb.ToString().TrimEnd(); + ReplaceMessage(sb.ToString().TrimEnd()); } private void AddFileToGitIgnoreToolStripMenuItemClick(object sender, EventArgs e) @@ -3092,7 +3102,7 @@ void CreateToolStripItem(CommitTemplateItem item) { try { - Message.Text = item.Text; + ReplaceMessage(item.Text); Message.Focus(); } catch @@ -3183,7 +3193,7 @@ private void Amend_CheckedChanged(object sender, EventArgs e) { if (string.IsNullOrEmpty(Message.Text) && Amend.Checked) { - Message.Text = Module.GetPreviousCommitMessages(1).FirstOrDefault()?.Trim(); + ReplaceMessage(Module.GetPreviousCommitMessages(1).FirstOrDefault()?.Trim()); } if (AppSettings.CommitAndPushForcedWhenAmend) diff --git a/GitUI/SpellChecker/EditNetSpell.cs b/GitUI/SpellChecker/EditNetSpell.cs index b77636f1622..dea3e13c795 100644 --- a/GitUI/SpellChecker/EditNetSpell.cs +++ b/GitUI/SpellChecker/EditNetSpell.cs @@ -193,7 +193,12 @@ public virtual int SelectionLength public virtual string SelectedText { get => TextBox.SelectedText; - set => TextBox.SelectedText = value; + set + { + HideWatermark(); + TextBox.SelectedText = value; + ShowWatermark(); + } } protected RepoDistSettings Settings => Module.EffectiveSettings ?? AppSettings.SettingsContainer; diff --git a/UnitTests/GitCommandsTests/CommitMessageManagerTests.cs b/UnitTests/GitCommandsTests/CommitMessageManagerTests.cs new file mode 100644 index 00000000000..19d1b39c463 --- /dev/null +++ b/UnitTests/GitCommandsTests/CommitMessageManagerTests.cs @@ -0,0 +1,273 @@ +using System; +using System.IO; +using System.IO.Abstractions; +using System.Text; +using FluentAssertions; +using GitCommands; +using NSubstitute; +using NUnit.Framework; + +namespace GitCommandsTests +{ + [TestFixture] + public class CommitMessageManagerTests + { + private const string _commitMessage = "commit message"; + private const string _mergeMessage = "merge message"; + private const string _newMessage = "new message"; + + private readonly string _workingDirGitDir = @"c:\dev\repo\.git"; + private readonly Encoding _encoding = Encoding.UTF8; + + private readonly string _amendSaveStatePath; + private readonly string _commitMessagePath; + private readonly string _mergeMessagePath; + private readonly bool _rememberAmendCommitState; + + private FileBase _file; + private IFileSystem _fileSystem; + private CommitMessageManager _manager; + + public CommitMessageManagerTests() + { + _amendSaveStatePath = Path.Combine(_workingDirGitDir, "GitExtensions.amend"); + _commitMessagePath = Path.Combine(_workingDirGitDir, "COMMITMESSAGE"); + _mergeMessagePath = Path.Combine(_workingDirGitDir, "MERGE_MSG"); + _rememberAmendCommitState = AppSettings.RememberAmendCommitState; + } + + [SetUp] + public void Setup() + { + _file = Substitute.For(); + _file.ReadAllText(_commitMessagePath, _encoding).Returns(_commitMessage); + _file.ReadAllText(_mergeMessagePath, _encoding).Returns(_mergeMessage); + + var path = Substitute.For(); + path.Combine(Arg.Any(), Arg.Any()).Returns(x => Path.Combine((string)x[0], (string)x[1])); + + _fileSystem = Substitute.For(); + _fileSystem.File.Returns(_file); + _fileSystem.Path.Returns(path); + + _manager = CommitMessageManager.TestAccessor.Construct(_workingDirGitDir, _encoding, _fileSystem); + } + + [TearDown] + public void TearDown() + { + AppSettings.RememberAmendCommitState = _rememberAmendCommitState; + } + + [TestCase(null)] + public void Constructor_should_throw(string workingDirGitDir) + { + ((Action)(() => new CommitMessageManager(workingDirGitDir, _encoding))).Should().Throw(); + } + + [TestCase("")] + [TestCase(" ")] + [TestCase("::")] + public void Constructor_should_not_throw(string workingDirGitDir) + { + new CommitMessageManager(workingDirGitDir, _encoding).Should().NotBeNull(); + } + + [Test] + public void AmendState_should_be_false_if_file_is_missing() + { + _file.Exists(_amendSaveStatePath).Returns(false); + + AppSettings.RememberAmendCommitState = true; + _manager.AmendState.Should().BeFalse(); + } + + [Test] + public void AmendState_should_be_false_if_not_RememberAmendCommitState() + { + _file.Exists(_amendSaveStatePath).Returns(true); + + AppSettings.RememberAmendCommitState = false; + _manager.AmendState.Should().BeFalse(); + } + + [TestCase("")] + [TestCase(" ")] + [TestCase("\n")] + [TestCase("0")] + [TestCase("1")] + [TestCase("false")] + [TestCase("yes")] + [TestCase("on")] + [TestCase("checked")] + [TestCase("true.")] + [TestCase("true\nx")] + public void AmendState_should_be_false_if_file_contains(string amendText) + { + _file.Exists(_amendSaveStatePath).Returns(true); + _file.ReadAllText(_amendSaveStatePath).Returns(amendText); + + AppSettings.RememberAmendCommitState = true; + _manager.AmendState.Should().BeFalse(); + } + + [TestCase("true")] + [TestCase("True")] + [TestCase("TrUe")] + [TestCase("true ")] + [TestCase("true\n")] + public void AmendState_should_be_true_if_file_contains(string amendText) + { + _file.Exists(_amendSaveStatePath).Returns(true); + _file.ReadAllText(_amendSaveStatePath).Returns(amendText); + + AppSettings.RememberAmendCommitState = true; + _manager.AmendState.Should().BeTrue(); + } + + [Test] + public void AmendState_true_should_write_true_to_file() + { + bool correctlyWritten = false; + _file.When(x => x.WriteAllText(_amendSaveStatePath, true.ToString())).Do(_ => correctlyWritten = true); + + AppSettings.RememberAmendCommitState = true; + _manager.AmendState = true; + + Assert.That(correctlyWritten); + } + + [Test] + public void AmendState_true_should_delete_file_if_not_RememberAmendCommitState() + { + bool correctlyDeleted = false; + _file.When(x => x.Delete(_amendSaveStatePath)).Do(_ => correctlyDeleted = true); + + AppSettings.RememberAmendCommitState = false; + _manager.AmendState = true; + + Assert.That(correctlyDeleted); + } + + [TestCase(true)] + [TestCase(false)] + public void AmendState_false_should_delete_file(bool rememberAmendCommitState) + { + bool correctlyDeleted = false; + _file.When(x => x.Delete(_amendSaveStatePath)).Do(_ => correctlyDeleted = true); + + AppSettings.RememberAmendCommitState = rememberAmendCommitState; + _manager.AmendState = false; + + Assert.That(correctlyDeleted); + } + + [Test] + public void CommitMessagePath() + { + _manager.CommitMessagePath.Should().Be(_commitMessagePath); + } + + [Test] + public void MergeOrCommitMessage_should_return_merge_message_if_exists() + { + _file.Exists(_commitMessagePath).Returns(true); + _file.Exists(_mergeMessagePath).Returns(true); + + _manager.MergeOrCommitMessage.Should().Be(_mergeMessage); + + _manager.IsMergeCommit.Should().BeTrue(); + } + + [Test] + public void MergeOrCommitMessage_should_return_commit_message_if_exists_and_no_merge_message() + { + _file.Exists(_commitMessagePath).Returns(true); + _file.Exists(_mergeMessagePath).Returns(false); + + _manager.MergeOrCommitMessage.Should().Be(_commitMessage); + + _manager.IsMergeCommit.Should().BeFalse(); + } + + [Test] + public void MergeOrCommitMessage_should_return_empty_if_no_file_exists() + { + _file.Exists(_commitMessagePath).Returns(false); + _file.Exists(_mergeMessagePath).Returns(false); + + _manager.MergeOrCommitMessage.Should().BeEmpty(); + + _manager.IsMergeCommit.Should().BeFalse(); + } + + [Test] + public void MergeOrCommitMessage_should_write_merge_message_if_exists() + { + bool correctlyWritten = false; + _file.When(x => x.WriteAllText(_mergeMessagePath, _newMessage, _encoding)).Do(_ => correctlyWritten = true); + _file.Exists(_commitMessagePath).Returns(true); + _file.Exists(_mergeMessagePath).Returns(true); + + _manager.MergeOrCommitMessage = _newMessage; + + Assert.That(correctlyWritten); + } + + [Test] + public void MergeOrCommitMessage_should_write_commit_message_if_exists_and_no_merge_message() + { + bool correctlyWritten = false; + _file.When(x => x.WriteAllText(_commitMessagePath, _newMessage, _encoding)).Do(_ => correctlyWritten = true); + _file.Exists(_commitMessagePath).Returns(true); + _file.Exists(_mergeMessagePath).Returns(false); + + _manager.MergeOrCommitMessage = _newMessage; + + Assert.That(correctlyWritten); + } + + [Test] + public void MergeOrCommitMessage_should_write_commit_message_if_no_file_exists() + { + bool correctlyWritten = false; + _file.When(x => x.WriteAllText(_commitMessagePath, _newMessage, _encoding)).Do(_ => correctlyWritten = true); + _file.Exists(_commitMessagePath).Returns(false); + _file.Exists(_mergeMessagePath).Returns(false); + + _manager.MergeOrCommitMessage = _newMessage; + + Assert.That(correctlyWritten); + } + + [Test] + public void MergeOrCommitMessage_should_write_empty_message_if_null() + { + bool correctlyWritten = false; + _file.When(x => x.WriteAllText(_commitMessagePath, string.Empty, _encoding)).Do(_ => correctlyWritten = true); + _file.Exists(_commitMessagePath).Returns(false); + _file.Exists(_mergeMessagePath).Returns(false); + + _manager.MergeOrCommitMessage = null; + + Assert.That(correctlyWritten); + } + + [Test] + public void ResetCommitMessage() + { + bool deletedA = false; + bool deletedC = false; + bool deletedM = false; + _file.When(x => x.Delete(_amendSaveStatePath)).Do(_ => deletedA = true); + _file.When(x => x.Delete(_commitMessagePath)).Do(_ => deletedC = true); + _file.When(x => x.Delete(_mergeMessagePath)).Do(_ => deletedM = true); + + _manager.ResetCommitMessage(); + + Assert.That(deletedA); + Assert.That(deletedC); + Assert.That(!deletedM); + } + } +} \ No newline at end of file diff --git a/UnitTests/GitCommandsTests/GitCommandsTests.csproj b/UnitTests/GitCommandsTests/GitCommandsTests.csproj index 2ed934f3d60..32ea19b6e58 100644 --- a/UnitTests/GitCommandsTests/GitCommandsTests.csproj +++ b/UnitTests/GitCommandsTests/GitCommandsTests.csproj @@ -52,6 +52,7 @@ + diff --git a/UnitTests/GitUITests/CommandsDialogs/ReferenceRepository.cs b/UnitTests/GitUITests/CommandsDialogs/ReferenceRepository.cs index 6bed68e6efe..767341d9fe3 100644 --- a/UnitTests/GitUITests/CommandsDialogs/ReferenceRepository.cs +++ b/UnitTests/GitUITests/CommandsDialogs/ReferenceRepository.cs @@ -74,7 +74,7 @@ public void Reset() repository.RemoveUntrackedFiles(); } - CommitHelper.SetCommitMessage(Module, commitMessageText: null, amendCommit: false); + new CommitMessageManager(Module.WorkingDirGitDir, Module.CommitEncoding).ResetCommitMessage(); } public void Dispose()