-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #784 from adamralph/no-git
NoGit
- Loading branch information
Showing
20 changed files
with
120 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace MinVer.Lib; | ||
|
||
#pragma warning disable CA1032 // Implement standard exception constructors | ||
public class NoGitException : Exception | ||
#pragma warning restore CA1032 | ||
{ | ||
public NoGitException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Runtime.InteropServices; | ||
using Xunit; | ||
|
||
namespace MinVerTests.Packages.Infra; | ||
|
||
internal sealed class WindowsFactAttribute : FactAttribute | ||
{ | ||
public override string Skip | ||
{ | ||
get => !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Windows only" : base.Skip; | ||
set => base.Skip = value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using MinVerTests.Infra; | ||
using MinVerTests.Packages.Infra; | ||
using Xunit; | ||
|
||
namespace MinVerTests.Packages; | ||
|
||
public static class NoGit | ||
{ | ||
[WindowsFact] | ||
public static async Task GitIsNotInPath() | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
await Sdk.CreateProject(path); | ||
await Git.Init(path); | ||
await Git.Commit(path); | ||
|
||
var pathEnvVar = Environment.GetEnvironmentVariable("PATH") ?? ""; | ||
pathEnvVar = pathEnvVar.Replace("git", "not-git", true, CultureInfo.InvariantCulture); | ||
|
||
var sdkExitCode = 0; | ||
var cliExitCode = 0; | ||
|
||
// act | ||
var (_, sdkStandardOutput, _) = await Sdk.BuildProject( | ||
path, | ||
exitCode => | ||
{ | ||
sdkExitCode = exitCode; | ||
return true; | ||
}, | ||
("PATH", pathEnvVar)); | ||
|
||
var (_, cliStandardError) = await MinVerCli.ReadAsync( | ||
path, | ||
handleExitCode: exitCode => | ||
{ | ||
cliExitCode = exitCode; | ||
return true; | ||
}, | ||
envVars: ("PATH", pathEnvVar)); | ||
|
||
// assert | ||
Assert.NotEqual(0, sdkExitCode); | ||
Assert.Contains("MINVER1007", sdkStandardOutput, StringComparison.Ordinal); | ||
|
||
Assert.NotEqual(0, cliExitCode); | ||
Assert.Contains("\"git\" is not present in PATH.", cliStandardError, StringComparison.Ordinal); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters