Skip to content

Commit

Permalink
Shield from invalid git version
Browse files Browse the repository at this point in the history
It seems sometimes `git --version` might return something that isn't a valid version number we can parse into major.minor.code.

The warning can be ignored with the code `GI007`.

Fixes #300
  • Loading branch information
kzu committed Aug 30, 2023
1 parent 340ef4a commit d1eee82
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/GitInfo/build/GitInfo.targets
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@
<_GitCurrentVersion>$([System.Text.RegularExpressions.Regex]::Match("$(_GitOutput)", "\d+\.\d+\.\d+").Value)</_GitCurrentVersion>
</PropertyGroup>

<Error Condition="$([System.Version]::Parse('$(_GitCurrentVersion)').CompareTo($([System.Version]::Parse('$(GitMinVersion)')))) &lt; 0"
Text="Required minimum git version is $(GitMinVersion) but found $(_GitCurrentVersion)." />
<Warning Condition="$(_GitCurrentVersion) == ''"
Code="GI007"
Text="Could not determine git version from output '$(_GitOutput)'. Required minimum git version is $(GitMinVersion)." />

<Error Condition="$(_GitCurrentVersion) != '' and $([System.Version]::Parse('$(_GitCurrentVersion)').CompareTo($([System.Version]::Parse('$(GitMinVersion)')))) &lt; 0"
Text="Required minimum git version is $(GitMinVersion) but found $(_GitCurrentVersion)." />
</Target>

<Target Name="_GitRoot" Returns="$(GitRoot)" Condition="'$(GitRoot)' == ''">
Expand Down

0 comments on commit d1eee82

Please sign in to comment.