Skip to content

Commit

Permalink
Update RemoveFiles to use GetBatchOutput.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianFreemanAtlanta committed Oct 9, 2020
1 parent 3083983 commit 18eb347
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
8 changes: 4 additions & 4 deletions GitCommands/Git/GitModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1373,13 +1373,13 @@ public string RemoveFiles(IReadOnlyList<string> files, bool force)
return "";
}

return _gitExecutable.GetOutput(
return _gitExecutable.GetBatchOutput(
new GitArgumentBuilder("rm")
{
{ force, "--force" },
"--",
files.Select(f => f.ToPosixPath().Quote())
});
"--"
}
.BuildBatchArgumentsForFiles(files));
}

/// <summary>Tries to start Pageant for the specified remote repo (using the remote's PuTTY key file).</summary>
Expand Down
20 changes: 20 additions & 0 deletions UnitTests/GitCommands.Tests/GitModuleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,26 @@ public void ResetFiles_should_work_as_expected(string[] files, string args)
}
}

[TestCase(new string[] { "abc", "def" }, "rm -- \"abc\" \"def\"")]
public void RemoveFiles_shouldWorkAsExpected(string[] files, string args)
{
// Real GitModule is need to access AppSettings.GitCommand static property, avoid exception with dummy GitModule
using (var moduleTestHelper = new GitModuleTestHelper())
{
var gitModule = GetGitModuleWithExecutable(_executable, module: moduleTestHelper.Module);
string dummyCommandOutput = "The answer is 42. Just check that the Git arguments are as expected.";
_executable.StageOutput(args, dummyCommandOutput);
var result = gitModule.RemoveFiles(files.ToList(), false);
Assert.AreEqual(dummyCommandOutput, result);
}
}

[TestCase(new string[] { }, "")]
public void RemoveFiles_should_handle_empty_list(string[] files, string expectedOutput)
{
Assert.AreEqual(expectedOutput, _gitModule.RemoveFiles(files.ToList(), false));
}

[TestCaseSource(nameof(BatchUnstageFilesTestCases))]
public void BatchUnstageFiles_should_work_as_expected(GitItemStatus[] files, string[] args, bool expectedResult)
{
Expand Down
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,4 @@ YYYY/MM/DD, github id, Full name, email
2020/07/11, blitzmann, Ryan Holmes, holmes.ryan.90(at)gmail.com
2020/10/01, racecrew, Otis Hix, otis.hix(at)protonmail.com
2020/10/04, GintasS, Gintautas Švedas, svedgintas(at)gmail.com
2020/10/09, BrianFreemanAtlanta, Brian Freeman, freeman(at)carnegie.com

0 comments on commit 18eb347

Please sign in to comment.