Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions NetRevisionTask/RevisionFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ public string Resolve(string format)
}

string tagName = RevisionData.Tag;
if (RemoveTagV && Regex.IsMatch(tagName, "^v[0-9]"))
{
// This detects any pattern of v1 to v1.2.3-foo.
// It is way more complex, but can also trim tags like "project-one/v1.2.3-alpha2".
// These tag-types are often used by mono-repositories.
string versionPattern = @"v([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)(?:-(.+))?$";
if (RemoveTagV && Regex.IsMatch(tagName, versionPattern))
{
// Replace anything around the pattern.
tagName = tagName.Replace(Regex.Replace(tagName, versionPattern, ""), "");
// Remove the "v" at the start.
tagName = tagName.Substring(1);
}
format = format.Replace("{semvertag}", GetSemVerTagSpec(tagName));
Expand Down