Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SemanticVersion.TryParse() vs. TagPrefix #495

Closed
Tungsten78 opened this issue Jul 13, 2015 · 2 comments
Closed

SemanticVersion.TryParse() vs. TagPrefix #495

Tungsten78 opened this issue Jul 13, 2015 · 2 comments

Comments

@Tungsten78
Copy link

First off, great work on this tool! You guys have put together something great.

I've been trying to integrate GitVersion (v3.0.0-beta.4) into our build process and have been running into issues with respect to the tag strategies. Our build server tags our repository with a build tag of the form "build/product/branch/1.2.3". This allows our team to easily track commits back to the most recent build.

The issue stems from GitVersion using these tags within TrackMergeTargetBaseVersionStrategy and TaggedCommitVersionStrategy. Given the default prefix of [vV] we expected that our tags would be ignored.

I was looking at the commit that added TagPrefix (JakeGinnivan@31d4208) and it seems from the unit tests that the intent was to be more flexible when parsing tags (instead of only allowing an optional v). What's odd is that regardless of what we use for TagPrefix the result is always successful.

Consider (tagprefix changed):

    [Test]
    public void CanSpecifyTagPrefixes()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config { TagPrefix = "SomethingOfftheWall" }))
        {
            const string TaggedVersion = "version-1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.MakeCommits(5);
            fixture.AssertFullSemver("1.0.4+5");
        }
    }

Here's a failed test to illustrate what I was expecting:

[Test]
    public void AreTagsNotAdheringToTagPrefixIgnored()
    {
        using (var fixture = new EmptyRepositoryFixture(new Config { TagPrefix = "" }))
        {
            string TaggedVersion = "version-1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);
            fixture.Repository.MakeCommits(5);

            fixture.AssertFullSemver("0.1.0+5");    //Fallback version + 5 commits since tag

            TaggedVersion = "bad/1.0.3";
            fixture.Repository.MakeATaggedCommit(TaggedVersion);

            fixture.AssertFullSemver("0.1.0+6");   //Fallback version + 6 commits since tag
        }
    }

I've made a few edits (master...Tungsten78:AddressTagParsing) to the regular expression to modify this behavior. The changes involve adding start (^) and end ($) constraints to the regular expressions to ensure that the match applies to the entire tag string.

Also, whether the TagPrefix is optional is now specified in the prefix itself (ie: TagPrefix= "[vV]|"). This was made the default configuration.

@JakeGinnivan
Copy link
Contributor

I have opened a PR, the changes look good. If the build passes I will merge

Thanks for the fixes!

@JakeGinnivan
Copy link
Contributor

Merged into master via 50833b4

Thanks!

Tungsten78 pushed a commit to Tungsten78/GitVersion that referenced this issue Jul 14, 2015
… intended with default TagPrefix of "[vV]|"
Tungsten78 pushed a commit to Tungsten78/GitVersion that referenced this issue Jul 15, 2015
…at resulted from a partial merge of pull request. More specifically TagPrefix is always considered optional.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants