Skip to content

Commit

Permalink
fix: incrementing stops after a version tag (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewingjm committed Dec 13, 2023
1 parent eac6865 commit 77b411d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/PowerVersion/Repositories/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,19 @@ public GitTag GetTag(string reference = "HEAD", string match = "*")

try
{
tag = this.ExecuteCommand($"describe --tags --abbrev=0 --match \"{match}\" {reference}");
tag = this.ExecuteCommand($"describe --tags --abbrev=7 --match \"{match}\" {reference}");
}
catch (Exception ex) when (ex.Message.Contains("fatal: No names found, cannot describe anything."))
{
return null;
}

var regexMatch = Regex.Match(tag, $"^(?<tag>.+)(-(?<additionalCommits>\\d+)-g(?<commitHash>.+))?$");
var regexMatch = Regex.Match(tag, @"^(?<tag>.+)-(?<additionalCommits>\d+)-g(?<commitHash>.+)$");

return new GitTag(
regexMatch.Groups["tag"].ToString(),
regexMatch.Groups["commitHash"].Success ? regexMatch.Groups["commitHash"].ToString() : this.GetCommit().Hash);
var tagName = regexMatch.Success ? regexMatch.Groups["tag"].ToString() : tag;
var tagCommit = this.ExecuteCommand($"rev-list -n 1 --abbrev-commit {tagName}");

return new GitTag(tagName, tagCommit);
}

/// <inheritdoc/>
Expand Down

0 comments on commit 77b411d

Please sign in to comment.