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

[Bug] merge-message-formats gets overwritten #2371

Closed
chrisism opened this issue Jul 30, 2020 · 5 comments · Fixed by #2376
Closed

[Bug] merge-message-formats gets overwritten #2371

chrisism opened this issue Jul 30, 2020 · 5 comments · Fixed by #2376
Labels
Milestone

Comments

@chrisism
Copy link

Describe the bug
When you set your own custom merge-message-formats it will get overwritten when applying gitversion.
Running the gitversion /showConfig will just show a emtpy dictionary again :
commit-date-format: yyyy-MM-dd merge-message-formats: {} update-build-number: true

Expected Behavior

When I insert a custom merge-message-format I expect it to end up in the combined config and applied during gitversion action.

Actual Behavior

merge-message-formats stays { }

Possible Fix

The default Config() that is used as override in ConfigProvider has by default an empty dictionary for mergemessageformats, which will then override the custom dictionary because it only checks for NULL value. Merge dictionaries instead of override.

Steps to Reproduce

Alter gitversion.yml with:
merge-message-formats: tfs:'^Merged (?:PR (?<PullRequestNumber>\d+)): (M|m)erge (?<SourceBranch>.+) (in)?to (?<TargetBranch>.+)'
execute: gitversion /showConfig
Result:
ignore: sha: [] commit-date-format: yyyy-MM-dd merge-message-formats: {} update-build-number: true

Context

Now I can only use tags for incrementing. All my build pipelines in azure devops are now getting incorrect versions.

Your Environment

Azure devops, using latest gittools task as.

@chrisism chrisism added the bug label Jul 30, 2020
@chrisism
Copy link
Author

Possible fix:
Class: ConfigurationBuilder.cs
Method: ApplyOverrides(..)
Line: 63 change to
targetConfig.MergeMessageFormats = overrideConfig.MergeMessageFormats.Any() ? overrideConfig.MergeMessageFormats : targetConfig.MergeMessageFormats;

@asbjornu
Copy link
Member

Since you have a possible fix in place, do you think you could submit that change as a pull request, @chrisism?

@chrisism
Copy link
Author

chrisism commented Aug 3, 2020

Of course, here we go. #2376
Please take note that it isnt a proper fix yet, because it doesn't actually merge the two dictionaries. Just fix for incorrect NULL check.

@arturcic arturcic added this to the 5.5.0 milestone Oct 26, 2020
@arturcic
Copy link
Member

Closed by #2376

@arturcic
Copy link
Member

🎉 This issue has been resolved in version 5.5.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

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

Successfully merging a pull request may close this issue.

3 participants