Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix gitextensions#3501
* Add unit tests for fix gitextensions#3501
  • Loading branch information
aivanov-oneinc authored and RussKie committed Jan 31, 2018
1 parent ec750e0 commit e6cf41f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions GitCommands/Git/GitModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,10 @@ public string CommitCmd(bool amend, bool signOff = false, string author = "", bo
command += " --signoff";

if (!string.IsNullOrEmpty(author))
{
author = author.Trim().Trim('"');
command += " --author=\"" + author + "\"";
}

if (useExplicitCommitMessage)
{
Expand Down
1 change: 1 addition & 0 deletions UnitTests/GitCommandsTests/GitCommandsTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="FileAssociatedIconProviderTests.cs" />
<Compile Include="FullPathResolverTests.cs" />
<Compile Include="GitExtLinks\GitExtLinksTests.cs" />
<Compile Include="GitModuleTest.cs" />
<Compile Include="GitRevisionInfoProviderTests.cs" />
<Compile Include="Git\EncodingHelperTest.cs" />
<Compile Include="Git\GitBlameHeaderTest.cs" />
Expand Down
25 changes: 25 additions & 0 deletions UnitTests/GitCommandsTests/GitModuleTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using GitCommands;
using NUnit.Framework;

namespace GitCommandsTests
{
[TestFixture]
public class GitModuleTest
{
GitModule _gitModule;
[SetUp]
public void SetUp()
{
_gitModule = new GitModule(null);
}

[TestCase(@" ""author <author@mail.com>"" ", @"commit --author=""author <author@mail.com>"" -F ""COMMITMESSAGE""")]
[TestCase(@"""author <author@mail.com>""", @"commit --author=""author <author@mail.com>"" -F ""COMMITMESSAGE""")]
[TestCase(@"author <author@mail.com>", @"commit --author=""author <author@mail.com>"" -F ""COMMITMESSAGE""")]
public void CommitCmdShouldTrimAuthor(string input, string expected)
{
var actual = _gitModule.CommitCmd(false, author: input);
StringAssert.AreEqualIgnoringCase(expected, actual);
}
}
}

0 comments on commit e6cf41f

Please sign in to comment.