Skip to content

Merge message parser does not work for merge commits created by TFS #1628

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

Closed
kelly987654 opened this issue Mar 7, 2019 · 14 comments
Closed
Labels

Comments

@kelly987654
Copy link

kelly987654 commented Mar 7, 2019

TFS automatically prepends the PR# to the merge commit message, which prevents the Regex matches of merge commit messages to properly detect the base version.

For ex. if the PR title is 'Merge release/2.3.1 to master', the merge commit automatically created by TFS on completion of the PR is 'Merged PR 12345: Merge release/2.3.1 to master'

Expected version: 2.3.1+0
Actual version: 2.3.1+688

Removing the '^' at the beginning of the Regex expressions in MergeMessage.cs would fix the issue.

This issue appeared after updating to GitVersion 4, we did not have this issue in version 3.

@stale
Copy link

stale bot commented Jun 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 29, 2019
@kelly987654
Copy link
Author

Any thoughts on this? This issue prevents us from using the latest GitVersion, since we cannot control the merge commit message created by TFS.

@stale stale bot removed the stale label Jul 10, 2019
@stale
Copy link

stale bot commented Oct 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 8, 2019
@kelly987654
Copy link
Author

Still hoping for a fix on this

@stale stale bot removed the stale label Oct 8, 2019
@asbjornu
Copy link
Member

asbjornu commented Oct 8, 2019

I'd think #1488 should help fix this issue for you. Have you looked into configuring merge-message-formats? Now I just discovered that although #1488 provided documentation, that documentation doesn't seem to have been published on Read The Docs. Any idea why that might be, @arturcic?

@kelly987654
Copy link
Author

Thanks @asbjornu! I will test it out.

@stale
Copy link

stale bot commented Jan 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 6, 2020
@asbjornu
Copy link
Member

asbjornu commented Jan 7, 2020

The documentation for merge-message-formats is now live on gitversion.net.

@stale stale bot removed the stale label Jan 7, 2020
@kelly987654
Copy link
Author

kelly987654 commented Jan 7, 2020

@asbjornu Thanks - I tried it exactly from the documentation, and it didn't work. I eventually got it working after adding quotes around the regex.

This failed due to an error parsing the YAML:

merge-message-formats:
    tfs: ^Merged (?:PR (?<PullRequestNumber>\d+)): Merge (?<SourceBranch>.+) to (?<TargetBranch>.+)

This worked:

merge-message-formats:
    tfs: '^Merged (?:PR (?<PullRequestNumber>\d+)): Merge (?<SourceBranch>.+) to (?<TargetBranch>.+)'

@kelly987654
Copy link
Author

The original issue seems to be resolved however, thank you for the help.

One other question if you don't mind - we are having issues where users creating the pull request from the release branch to master don't use the exact right syntax (e.g. 'merge release 1.0.0 into master' instead of 'merge release/1.0.0 to master'). And TFS has unfortunately removed the auto-complete of the merge message title.

Is there any setting or suggestion to designate the commit created by the merge from the release branch into master as the version specified by the release branch name?

@asbjornu
Copy link
Member

asbjornu commented Jan 8, 2020

@kelly987654, yes – YAML requires strings to be wrapped in quotation marks. The release branch name should affect the version number, as long as it's identified as a release branch by GitVersion. How do you name your release branches? If you use release/ or release- as a prefix, GitVersion should identify it automatically.

@kelly987654
Copy link
Author

kelly987654 commented Jan 8, 2020

@asbjornu : Thank you!

Our workflow is as follows:

  • master: gitversion is 1.1.0
  • develop: gitversion is 1.2.0-dev.88
  • create new branch from develop named release/1.2.0: gitversion is 1.2.0-rc.0
  • merge release/1.2.0 into master:
    • If we don't name the Pull Request title (merge message) exactly right, master branch gitversion is 1.1.1

I tried with GitVersion 5.1.2, as well as the much older version (3.6.5), and it seems that GitVersion only uses the merge message to detect if the release branch was merged into master, and if the merge message isn't formatted correctly, it will default to the branch's default increment (Patch).

Are we missing some other step or configuration that would allow us to be more flexible with the exact merge commit message? We can add some more regex options in the merge-message-formats configuration, but I was hoping it was possible that GitVersion could just tell that the release branch was merged into master without relying on the merge message.

@asbjornu
Copy link
Member

You might be right. I don't remember exactly how the release detection is performed.

@kelly987654
Copy link
Author

kelly987654 commented Jan 14, 2020

Okay thanks - we will look into using a hook to enforce a well formatted merge message. I just wanted to make sure we weren't missing a simple setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants