-
Notifications
You must be signed in to change notification settings - Fork 652
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 #3975 from arturcic/main
cleanups & refactorings
- Loading branch information
Showing
193 changed files
with
836 additions
and
943 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
2 changes: 1 addition & 1 deletion
2
new-cli/GitVersion.Core.Libgit2Sharp/Git/GitRepository.extended.cs
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace GitVersion; | ||
namespace GitVersion.Git; | ||
|
||
internal sealed partial class GitRepository : IGitRepository | ||
{ | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using GitVersion.Git; | ||
using GitVersion.Infrastructure; | ||
|
||
namespace GitVersion; | ||
|
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,78 @@ | ||
using System.Text.RegularExpressions; | ||
using GitVersion.Helpers; | ||
|
||
namespace GitVersion; | ||
|
||
internal static class ArgumentParserExtensions | ||
{ | ||
private static readonly string[] TrueValues = ["1", "true"]; | ||
private static readonly string[] FalseValues = ["0", "false"]; | ||
|
||
public static bool IsTrue(this string? value) => TrueValues.Contains(value, StringComparer.OrdinalIgnoreCase); | ||
|
||
public static bool IsFalse(this string? value) => FalseValues.Contains(value, StringComparer.OrdinalIgnoreCase); | ||
|
||
public static bool IsValidPath(this string? path) | ||
{ | ||
if (path == null) | ||
return false; | ||
|
||
try | ||
{ | ||
_ = PathHelper.GetFullPath(path); | ||
} | ||
catch | ||
{ | ||
path = PathHelper.Combine(SysEnv.CurrentDirectory, path); | ||
|
||
try | ||
{ | ||
_ = PathHelper.GetFullPath(path); | ||
} | ||
catch | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
return Directory.Exists(path); | ||
} | ||
|
||
public static bool IsSwitchArgument(this string? value) | ||
=> value != null | ||
&& (value.StartsWith('-') || value.StartsWith('/')) | ||
&& !Regex.Match(value, @"/\w+:").Success; //Exclude msbuild & project parameters in form /blah:, which should be parsed as values, not switch names. | ||
|
||
public static bool IsSwitch(this string? value, string switchName) | ||
{ | ||
if (value == null) | ||
return false; | ||
|
||
if (value.StartsWith('-')) | ||
{ | ||
value = value[1..]; | ||
} | ||
|
||
if (value.StartsWith('/')) | ||
{ | ||
value = value[1..]; | ||
} | ||
|
||
return string.Equals(switchName, value, StringComparison.OrdinalIgnoreCase); | ||
} | ||
|
||
public static bool IsHelp(this string singleArgument) => (singleArgument == "?") || singleArgument.IsSwitch("h") || singleArgument.IsSwitch("help") || singleArgument.IsSwitch("?"); | ||
|
||
public static bool ArgumentRequiresValue(this string argument, int argumentIndex) | ||
{ | ||
var booleanArguments = new[] { "init", "updateassemblyinfo", "ensureassemblyinfo", "nofetch", "nonormalize", "nocache" }; | ||
|
||
var argumentMightRequireValue = !booleanArguments.Contains(argument[1..], StringComparer.OrdinalIgnoreCase); | ||
|
||
// If this is the first argument that might be a target path, the argument starts with slash and we're on an OS that supports paths with slashes, the argument does not require a value. | ||
if (argumentMightRequireValue && argumentIndex == 0 && argument.StartsWith('/') && Path.DirectorySeparatorChar == '/' && argument.IsValidPath()) | ||
return false; | ||
|
||
return argumentMightRequireValue; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using GitVersion.Git; | ||
using GitVersion.Logging; | ||
|
||
namespace GitVersion; | ||
|
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
1 change: 1 addition & 0 deletions
1
src/GitVersion.Configuration.Tests/Configuration/ConfigurationExtensionsTests.cs
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
Oops, something went wrong.