diff --git a/src/Vcs/Git/GitVcs.cs b/src/Vcs/Git/GitVcs.cs
index 3a3133d..116d6ed 100644
--- a/src/Vcs/Git/GitVcs.cs
+++ b/src/Vcs/Git/GitVcs.cs
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
+using System.IO;
namespace Skarp.Version.Cli.Vcs.Git
{
@@ -10,14 +11,15 @@ public class GitVcs : IVcs
///
/// Path to the cs project file that was version updated
/// The message to include in the commit
- public void Commit(string csProjFilePath, string message)
+ ///
+ public void Commit(string csProjFilePath, string message, string cwd = null)
{
- if(!LaunchGitWithArgs($"add \"{csProjFilePath}\""))
+ if(!LaunchGitWithArgs($"add \"{csProjFilePath}\"", cwd: cwd))
{
throw new OperationCanceledException($"Unable to add cs proj file {csProjFilePath} to git index");
}
- if(!LaunchGitWithArgs($"commit -m \"{message}\""))
+ if(!LaunchGitWithArgs($"commit -m \"{message}\"", cwd: cwd))
{
throw new OperationCanceledException("Unable to commit");
}
@@ -27,42 +29,54 @@ public void Commit(string csProjFilePath, string message)
/// Determines whether the current repository is clean.
///
///
- public bool IsRepositoryClean()
+ public bool IsRepositoryClean(string cwd = null)
{
- return LaunchGitWithArgs("diff-index --quiet HEAD --");
+ return LaunchGitWithArgs("diff-index HEAD --", cwd: cwd);
}
///
/// Determines whether git is present in PATH on the current computer
///
///
- public bool IsVcsToolPresent()
+ public bool IsVcsToolPresent(string cwd = null)
{
// launching `git --help` returns exit code 0 where as `git` returns 1 as git wants a cmd line argument
- return LaunchGitWithArgs("--help");
+ return LaunchGitWithArgs("--help", cwd: cwd);
}
///
/// Creates a new tag
///
/// Name of the tag
- public void Tag(string tagName)
+ ///
+ public void Tag(string tagName, string cwd = null)
{
- if(!LaunchGitWithArgs($"tag {tagName}"))
+ if(!LaunchGitWithArgs($"tag {tagName}", cwd: cwd))
{
throw new OperationCanceledException("Unable to create tag");
}
}
- private static bool LaunchGitWithArgs(string args, int waitForExitTimeMs = 1000, int exitCode = 0)
+ ///
+ /// Helper method for launching git with different arguments while returning just a boolean of whether the
+ /// "command" was successful
+ ///
+ /// The args to pass onto git, e.g `diff` to launch `git diff`
+ /// How long to wait for the git operation to complete
+ /// The expected exit code
+ /// The working directory to change into, if any. Leave null for "current directory"
+ ///
+ internal static bool LaunchGitWithArgs(
+ string args,
+ int waitForExitTimeMs = 1000,
+ int exitCode = 0,
+ string cwd = null
+ )
{
try
{
- var startInfo = CreateGitShellStartInfo(args);
- var proc = Process.Start(startInfo);
- proc.WaitForExit(waitForExitTimeMs);
-
- return proc.ExitCode == exitCode;
+ var (procExitCode, stdOut, stdErr) = LaunchGitWithArgsInner(args, waitForExitTimeMs, cwd);
+ return procExitCode == exitCode;
}
catch (Exception ex)
{
@@ -71,15 +85,36 @@ private static bool LaunchGitWithArgs(string args, int waitForExitTimeMs = 1000,
}
}
- private static ProcessStartInfo CreateGitShellStartInfo(string args)
+ internal static (int ExitCode, string stdOut, string stdErr) LaunchGitWithArgsInner(
+ string args,
+ int waitForExitTimeMs,
+ string cwd = null
+ )
{
- return new ProcessStartInfo("git")
+ var startInfo = CreateGitShellStartInfo(args, cwd);
+ var proc = Process.Start(startInfo);
+ proc.WaitForExit(waitForExitTimeMs);
+
+ var stdOut = proc.StandardOutput.ReadToEnd();
+ var stdErr = proc.StandardError.ReadToEnd();
+ return (proc.ExitCode, stdOut,stdErr);
+ }
+
+ internal static ProcessStartInfo CreateGitShellStartInfo(string args, string cwd = null)
+ {
+ var procInfo = new ProcessStartInfo("git")
{
Arguments = args,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
};
+
+ if (!string.IsNullOrWhiteSpace(cwd))
+ {
+ procInfo.WorkingDirectory = cwd;
+ }
+ return procInfo;
}
public string ToolName()
diff --git a/src/Vcs/IVcs.cs b/src/Vcs/IVcs.cs
index 40a28e3..7197220 100644
--- a/src/Vcs/IVcs.cs
+++ b/src/Vcs/IVcs.cs
@@ -16,15 +16,17 @@ public interface IVcs
/// are available in the current CLI contenxt - i.e check that `git` command can be found
/// and executed
///
+ /// Change working directory - leave null for current directory
/// true if the tool exists, false otherwise
- bool IsVcsToolPresent();
+ bool IsVcsToolPresent(string cwd = null);
///
/// When implemented by a concrete class it returns true if the
/// current HEAD of the local repository is clean - i.e no pending changes
///
+ /// Change working directory - leave null for current directory
///
- bool IsRepositoryClean();
+ bool IsRepositoryClean(string cwd = null);
///
/// When implemented by a concrete class it allows to create a commit with the
@@ -32,13 +34,15 @@ public interface IVcs
///
/// Path to the cs project file
/// The message to create the commit message with
- void Commit(string csProjFilePath, string message);
+ /// Change working directory - leave null for current directory
+ void Commit(string csProjFilePath, string message, string cwd = null);
///
/// When implemented by a concrete class it will tag the latest commit with the
/// given tag name
///
/// The name of the tag to create - i.e v1.0.2
- void Tag(string tagName);
+ /// Change working directory - leave null for current directory
+ void Tag(string tagName, string cwd = null);
}
}
\ No newline at end of file
diff --git a/test/GitVcsTest.cs b/test/GitVcsTest.cs
deleted file mode 100644
index 3fa2f71..0000000
--- a/test/GitVcsTest.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using Skarp.Version.Cli.Vcs.Git;
-using Xunit;
-
-namespace Skarp.Version.Cli.Test
-{
- public class GitVcsTest
- {
- private readonly GitVcs _vcs;
-
- public GitVcsTest()
- {
- _vcs = new GitVcs();
- }
-
- [Fact(
- Skip = "Dont run on build servers"
- )]
- public void DetectingGitOnMachineWorks()
- {
- Assert.True(_vcs.IsVcsToolPresent());
- }
-
- [Fact(
- Skip = "Dont run on build servers"
- )]
- public void IsRepositoryCleanWorks()
- {
- Assert.True(_vcs.IsRepositoryClean());
- }
- }
-}
\ No newline at end of file
diff --git a/test/Vcs/Git/GitVcsTest.cs b/test/Vcs/Git/GitVcsTest.cs
new file mode 100644
index 0000000..f50d240
--- /dev/null
+++ b/test/Vcs/Git/GitVcsTest.cs
@@ -0,0 +1,78 @@
+using System;
+using System.IO;
+using Skarp.Version.Cli.Vcs.Git;
+using Xunit;
+
+namespace Skarp.Version.Cli.Test.Vcs.Git
+{
+ public class GitVcsTest : IClassFixture
+ {
+ private readonly GitVcsFixture _fixture;
+
+
+ public GitVcsTest(GitVcsFixture fixture)
+ {
+ _fixture = fixture;
+ }
+
+ [Fact]
+ public void ReturnsProperToolname()
+ {
+ Assert.Equal("git", _fixture.Vcs.ToolName());
+ }
+
+ [Fact]
+ public void DetectingGitOnMachineWorks()
+ {
+ Assert.True(_fixture.Vcs.IsVcsToolPresent(_fixture.AbsolutePathToGitTestDir));
+ }
+
+ [Fact]
+ public void IsRepositoryCleanWorks()
+ {
+ Assert.True(_fixture.Vcs.IsRepositoryClean(_fixture.AbsolutePathToGitTestDir));
+ }
+
+ [Fact]
+ public void CanCommit()
+ {
+ // arrange
+ var commitMessage = Guid.NewGuid().ToString("N");
+ var fileToCommit = "dotnet-version.dll";
+ File.Copy(fileToCommit, Path.Combine(_fixture.GitTestDir, fileToCommit));
+
+ // act
+ _fixture.Vcs.Commit(fileToCommit, commitMessage, _fixture.AbsolutePathToGitTestDir);
+
+ // assert
+
+ // grep the git-log for messages containing our guid message
+ var (
+ exitCode,
+ stdOut,
+ _
+ ) = GitVcs.LaunchGitWithArgsInner($"log --grep={commitMessage}", 1000,
+ _fixture.AbsolutePathToGitTestDir);
+ Assert.Equal(0, exitCode);
+ Assert.Contains(commitMessage, stdOut);
+ }
+
+ [Fact]
+ public void CanCreateTags()
+ {
+ var tagToMake = Guid.NewGuid().ToString("N");
+
+ _fixture.Vcs.Tag(tagToMake, _fixture.AbsolutePathToGitTestDir);
+
+ var (exitCode, stdOut, _) =
+ GitVcs.LaunchGitWithArgsInner(
+ "tag -l"
+ , 1000,
+ _fixture.AbsolutePathToGitTestDir
+ );
+
+ Assert.Equal(0, exitCode);
+ Assert.Contains(tagToMake, stdOut);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/Vcs/Git/GitVcsTestFixture.cs b/test/Vcs/Git/GitVcsTestFixture.cs
new file mode 100644
index 0000000..e6d49ba
--- /dev/null
+++ b/test/Vcs/Git/GitVcsTestFixture.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.IO.Compression;
+using System.Threading;
+using Skarp.Version.Cli.Vcs.Git;
+
+namespace Skarp.Version.Cli.Test.Vcs.Git
+{
+ public class GitVcsFixture : IDisposable
+ {
+ public readonly string GitTestDir;
+ public readonly GitVcs Vcs;
+ public readonly string AbsolutePathToGitTestDir;
+
+ public GitVcsFixture()
+ {
+ GitTestDir = "./target-git-dir";
+ AbsolutePathToGitTestDir = Path.Combine(
+ Directory.GetCurrentDirectory(),
+ GitTestDir
+ );
+ DirectoryDelete(GitTestDir, recursive: true);
+
+ ZipFile.ExtractToDirectory("./target-git.zip", "./");
+ Vcs = new GitVcs();
+
+ var (_, stdOut, _) =
+ GitVcs.LaunchGitWithArgsInner(
+ "config user.email",
+ 1000,
+ AbsolutePathToGitTestDir
+ );
+ if (string.IsNullOrWhiteSpace(stdOut))
+ {
+ GitVcs.LaunchGitWithArgs("config user.email nicklas@skarp.dk");
+ GitVcs.LaunchGitWithArgs("config user.name Nicklas Laine Overgaard");
+ }
+ }
+
+
+ private void DirectoryDelete(string dir, bool recursive)
+ {
+ try
+ {
+ Directory.Delete(dir, recursive);
+ }
+ // we don't want to fail at all if deleting the dir fails
+ catch (Exception ex)
+ {
+ }
+ }
+
+ public void Dispose()
+ {
+ DirectoryDelete(GitTestDir, recursive: true);
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/VersionCliTest.cs b/test/VersionCliTest.cs
index 32c4555..7831fb5 100644
--- a/test/VersionCliTest.cs
+++ b/test/VersionCliTest.cs
@@ -60,7 +60,7 @@ public void VersionCli_Bump_VersionPrefix()
[Fact]
public void VersionCli_throws_when_vcs_tool_is_not_present_and_doVcs_is_true()
{
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(false);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(false);
var ex = Assert.Throws(() => _cli.Execute(new VersionCliArgs{VersionBump = VersionBump.Major, DoVcs = true}));
Assert.Equal("Unable to find the vcs tool _FAKE_ in your path", ex.Message);
@@ -69,7 +69,7 @@ public void VersionCli_throws_when_vcs_tool_is_not_present_and_doVcs_is_true()
[Fact]
public void VersionCli_doesNotThrow_when_vcs_tool_is_not_present_if_doVcs_is_false()
{
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(false);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(false);
A.CallTo(() => _fileParser.Version).Returns("1.2.1");
A.CallTo(() => _fileParser.PackageVersion).Returns("1.2.1");
@@ -79,8 +79,8 @@ public void VersionCli_doesNotThrow_when_vcs_tool_is_not_present_if_doVcs_is_fal
[Fact]
public void VersionCli_throws_when_repo_is_not_clean_and_doVcs_is_true()
{
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(false);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(false);
var ex = Assert.Throws(() => _cli.Execute(new VersionCliArgs{VersionBump = VersionBump.Major, DoVcs = true}));
Assert.Equal("You currently have uncomitted changes in your repository, please commit these and try again",
@@ -90,8 +90,8 @@ public void VersionCli_throws_when_repo_is_not_clean_and_doVcs_is_true()
[Fact]
public void VersionCli_doesNotThrow_when_repo_is_not_clean_if_doVcs_is_false()
{
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(false);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(false);
A.CallTo(() => _fileParser.Version).Returns("1.2.1");
A.CallTo(() => _fileParser.PackageVersion).Returns("1.2.1");
@@ -102,10 +102,10 @@ public void VersionCli_doesNotThrow_when_repo_is_not_clean_if_doVcs_is_false()
public void VersionCli_can_bump_versions()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -130,10 +130,10 @@ public void VersionCli_can_bump_versions()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "v2.0.0")))
+ A.That.Matches(msg => msg == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "v2.0.0")))
+ A.That.Matches(tag => tag == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -141,10 +141,10 @@ public void VersionCli_can_bump_versions()
public void VersionCli_can_bump_pre_release_versions()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._ ,null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -169,10 +169,10 @@ public void VersionCli_can_bump_pre_release_versions()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "v2.0.0-next.0")))
+ A.That.Matches(msg => msg == "v2.0.0-next.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "v2.0.0-next.0")))
+ A.That.Matches(tag => tag == "v2.0.0-next.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -180,10 +180,10 @@ public void VersionCli_can_bump_pre_release_versions()
public void VersionCli_can_bump_pre_release_with_custom_prefix()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -208,10 +208,10 @@ public void VersionCli_can_bump_pre_release_with_custom_prefix()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
csProjFilePath,
- "v2.0.0-beta.0"))
+ "v2.0.0-beta.0", null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- "v2.0.0-beta.0"))
+ "v2.0.0-beta.0", null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -219,10 +219,10 @@ public void VersionCli_can_bump_pre_release_with_custom_prefix()
public void VersionCli_can_bump_pre_release_with_build_meta_versions()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._ ,null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -247,10 +247,10 @@ public void VersionCli_can_bump_pre_release_with_build_meta_versions()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "v2.0.0-next.0+master")))
+ A.That.Matches(msg => msg == "v2.0.0-next.0+master"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "v2.0.0-next.0+master")))
+ A.That.Matches(tag => tag == "v2.0.0-next.0+master"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -258,10 +258,10 @@ public void VersionCli_can_bump_pre_release_with_build_meta_versions()
public void VersionCli_can_bump_versions_can_skip_vcs()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -283,18 +283,18 @@ public void VersionCli_can_bump_versions_can_skip_vcs()
A.CallTo(() => _filePatcher.Flush(
A.That.Matches(path => path == csProjFilePath)))
.MustHaveHappened(Repeated.Exactly.Once);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).MustNotHaveHappened();
- A.CallTo(() => _vcsTool.Tag(A._)).MustNotHaveHappened();
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).MustNotHaveHappened();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).MustNotHaveHappened();
}
[Fact]
public void VersionCli_can_bump_versions_can_dry_run()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -320,18 +320,18 @@ public void VersionCli_can_bump_versions_can_dry_run()
A.CallTo(() => _filePatcher.Flush(
A.That.Matches(path => path == csProjFilePath)))
.MustNotHaveHappened();
- A.CallTo(() => _vcsTool.Commit(A._, A._)).MustNotHaveHappened();
- A.CallTo(() => _vcsTool.Tag(A._)).MustNotHaveHappened();
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).MustNotHaveHappened();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).MustNotHaveHappened();
}
[Fact]
public void VersionCli_can_set_vcs_commit_message()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -356,10 +356,10 @@ public void VersionCli_can_set_vcs_commit_message()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "commit message")))
+ A.That.Matches(msg => msg == "commit message"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "v2.0.0")))
+ A.That.Matches(tag => tag == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -367,10 +367,10 @@ public void VersionCli_can_set_vcs_commit_message()
public void VersionCli_can_set_vcs_commit_message_with_variables()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -396,10 +396,10 @@ public void VersionCli_can_set_vcs_commit_message_with_variables()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "bump from v1.2.1 to v2.0.0 at unit-test")))
+ A.That.Matches(msg => msg == "bump from v1.2.1 to v2.0.0 at unit-test"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "v2.0.0")))
+ A.That.Matches(tag => tag == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -407,10 +407,10 @@ public void VersionCli_can_set_vcs_commit_message_with_variables()
public void VersionCli_can_set_vcs_tag()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -435,10 +435,10 @@ public void VersionCli_can_set_vcs_tag()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "v2.0.0")))
+ A.That.Matches(msg => msg == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "vcs tag")))
+ A.That.Matches(tag => tag == "vcs tag"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
@@ -446,10 +446,10 @@ public void VersionCli_can_set_vcs_tag()
public void VersionCli_can_set_vcs_tag_with_variables()
{
// Configure
- A.CallTo(() => _vcsTool.IsRepositoryClean()).Returns(true);
- A.CallTo(() => _vcsTool.IsVcsToolPresent()).Returns(true);
- A.CallTo(() => _vcsTool.Commit(A._, A._)).DoesNothing();
- A.CallTo(() => _vcsTool.Tag(A._)).DoesNothing();
+ A.CallTo(() => _vcsTool.IsRepositoryClean(null)).Returns(true);
+ A.CallTo(() => _vcsTool.IsVcsToolPresent(null)).Returns(true);
+ A.CallTo(() => _vcsTool.Commit(A._, A._, null)).DoesNothing();
+ A.CallTo(() => _vcsTool.Tag(A._, null)).DoesNothing();
A.CallTo(() => _fileDetector.FindAndLoadCsProj(A._)).Returns("");
const string csProjFilePath = "/unit-test/test.csproj";
@@ -475,10 +475,10 @@ public void VersionCli_can_set_vcs_tag_with_variables()
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Commit(
A.That.Matches(path => path == csProjFilePath),
- A.That.Matches(msg => msg == "v2.0.0")))
+ A.That.Matches(msg => msg == "v2.0.0"), null))
.MustHaveHappened(Repeated.Exactly.Once);
A.CallTo(() => _vcsTool.Tag(
- A.That.Matches(tag => tag == "bump from v1.2.1 to v2.0.0 at unit-test")))
+ A.That.Matches(tag => tag == "bump from v1.2.1 to v2.0.0 at unit-test"), null))
.MustHaveHappened(Repeated.Exactly.Once);
}
}
diff --git a/test/target-git.zip b/test/target-git.zip
new file mode 100644
index 0000000..adcacb1
Binary files /dev/null and b/test/target-git.zip differ