Skip to content

Consecutive pushes to a pull request branch results in conflicting nuget versions #902

@simonejsing

Description

@simonejsing

When GitVersion runs on a PR branch the default logic is to capture the PR id from the branch name and use that for versioning. However, this results in conflicting Nuget version strings when a pull request branch is updated with additional changes.

E.g. assuming I'm proposing to merge a new feature into a repo, I submit a PR that gets the id 1234. Now when the build runs on VSTS it produces Nuget packages with the version number 0.1.0-PullRequest1234, if the build is successful these packages are published to a Nuget feed. Now a colleague gives me feedback on the PR, and I go back and implement these suggestions and push an update to the feed. VSTS build will now kick off a new build on the same branch, resulting in yet another Nuget package versioned 0.1.0-PullRequest1234, after the build completes the publish step fails and the CI build is now failed.

This behavior is governed by:
tag-number-pattern: '[/-](?<number>\d+)[-/]'

It seems to me that instead of this pattern dictating the number, it should dictate the tag name. E.g. I should be able to use:
tag-suffix-pattern: '[/-](?<number>\d+)[-/]'

Which would append the number to the tag, and keep the default numbering schema where it counts the number of commits. That would make the pull request generate unique Nuget version numbers like:
PullRequest1234-0001
PullRequest1234-0002
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions