-
Notifications
You must be signed in to change notification settings - Fork 652
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
Implements regular expression for determining version label #3687
Conversation
I've opened this as a draft as I'm not sure what documentation to update or extra tests to write (and where to put them). Some guidance is welcome :) |
Also, I'm not quite sure removing BranchPrefixToTrim is actually the better solution here. I'm no expert in Regex, but I don't see a way to capture the whole branch name while also having a prefix to match (fx. regex: Or maybe I've just messed it up and used the branch-matching regex property instead of what was ment in the issue. |
Hi Casper. Thank you for your PR. Could you please give an example in which circumstances you see problems? You have specified already the regular expression with e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't found anything special. All comments from me are just minor issues. Well done.
src/GitVersion.Core/Configuration/GitFlowConfigurationBuilder.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/Configuration/GitFlowConfigurationBuilder.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/Configuration/GitHubFlowConfigurationBuilder.cs
Outdated
Show resolved
Hide resolved
src/GitVersion.Core/Configuration/GitHubFlowConfigurationBuilder.cs
Outdated
Show resolved
Hide resolved
If you like you can create a unit test for:
and some integration test in:
If you not finding a test class which fits to your scenario please feel free and create a new one. |
Sure, As I said, I don't work much with Regex so I might just be too inexperienced, but let's say that you want branch configuration to match Can that be handled by using |
I've created a unit test for it, but I'm not really sure if an integration test makes sense. It's all about how the label is decided (which is covered by the unit test), not whether the label is added correctly to the final version strings. Other existing tests already takes care of that :) |
Yes exactly this is supported. That is the reason I have proposed to use capturing group because you can almost do everything. ;) |
You can see the integration tests as a mechanism to ensure your functionality from the user point of view. It's like an acceptance test. It is really no big deal and you can create it very easily. Please give it a try and just wirte your scenario as part of an integration test. You are always sure your feature will not break. Edit: Given a feature branch configuration with
When getting the semantic version on feature branch feature/4711_this-is-a-feature |
If you not mind could you please change the After this changes we can merge it to the main branch. Thank you very much for your ambition. |
I've tried to implement the example you've given but have run into an issue. In The RegexReplace is something I've copied from the existing code so I'm hesitant to modify it without consulting you first. Adding |
I changed the expression this morning (CET) so that should be ok. I've also fixed the tests now. |
@HHobeck please consider merging this, good stuff |
- Remove magic string 'useBranchName' - Merge branch configuration property BranchPrefixToTrim with Regex/RegularExpression to support dynamic named groups in the regular expression
Thank you @CasperWSchmidt for your contribution! |
Description
Related Issue
#3661
Motivation and Context
See related issue.
How Has This Been Tested?
Existing tests are all green.
Screenshots (if appropriate):
N/A
Checklist: