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

Support Regex for label property #3661

Closed
CasperWSchmidt opened this issue Aug 23, 2023 · 8 comments · Fixed by #3687
Closed

Support Regex for label property #3661

CasperWSchmidt opened this issue Aug 23, 2023 · 8 comments · Fixed by #3687
Labels
Milestone

Comments

@CasperWSchmidt
Copy link
Contributor

CasperWSchmidt commented Aug 23, 2023

Detailed Description

We're using Shortcut to manage stories and bugs. Shortcut can automatically generate branches based on features and chores in the format feature/sc-xxxx/description. Using the default regex ^features?[/-] to recognize branches, useBranchName (or {branchName}) we'll get tags with sc-xxxx-description but we'd like to only have the story id (sc-xxxx) as the tag.

I'll be happy to make a PR once this feature has been discussed.

Context

I'm unsure of the actual syntax, but perhaps something like label: regex sc-\d+ so that the code can recognize the regex prefix. This regex will then be executed against the branch name to retrieve the part of the branch name that is returned as the label

Possible Implementation

@HHobeck
Copy link
Contributor

HHobeck commented Aug 23, 2023

I like the idea. I would recomment to reuse the label and regex property in the branch related property section like:

  feature:
    label: '{BranchName}'
    regex: ^features?[\/-](?<BranchName>.+)

The important thing to notice here is that the user can use zero, one or more generic named capture groups in the regex of an branch which can be used in the label property per placeholder convention like {BranchName}. The useBranchName support needs to be removed in my opinion.

@asbjornu what do you think?

@asbjornu
Copy link
Member

I agree to remove the useBranchName token and instead allow string interpolation of any variable GitVersion exposes.

@HHobeck HHobeck added this to the 6.x milestone Aug 23, 2023
@CasperWSchmidt
Copy link
Contributor Author

That sounds awesome! Any ETA on a final release for 6.0.0?

@HHobeck
Copy link
Contributor

HHobeck commented Aug 24, 2023

That sounds awesome! Any ETA on a final release for 6.0.0?

Of course when the tickets are done for milestone 6!? 😅

@CasperWSchmidt
Copy link
Contributor Author

That sounds awesome! Any ETA on a final release for 6.0.0?

Of course when the tickets are done for milestone 6!? 😅

I can see that the milestone is 5% done, so I guess it will be a while :)

With a little guidance as to where and how you see this change made, I might be able to do this PR myself. Just let me know.

@HHobeck
Copy link
Contributor

HHobeck commented Aug 29, 2023

I can see that the milestone is 5% done, so I guess it will be a while :)

On the first glance the progress for 6.x seems to be not so advanced but some alpha and beta versions have been released already with alot of changes ;)

image

I would appreciate your help very much. Any features or bugs which can be finished will help to speed up the release.

With a little guidance as to where and how you see this change made, I might be able to do this PR myself. Just let me know.

Of course I can guide you to the right location. For the beginning I would say let's start with this feature. :)

@HHobeck
Copy link
Contributor

HHobeck commented Aug 29, 2023

Following steps I would recommend:

  • Rename BranchPrefixToTrim to RegularExpression
  • Remove all usage of useBranchName
  • Refactor the extension method GetBranchSpecificLabel:
    • Determine the capture groups (name and value) of the branch name using the regular expression
    • Iterate over the capturing groups and
    • replace the place holder of the name with the value in label
  • Adapt the RegularExpressions in GitFlow and GitHubFlowConfigurationBuilder to e.g. ^features?[\/-](?<BranchName>.+)
  • Adapt the base workspace template in
    • src\GitVersion.Core\Configuration\SupportedWorkflows\GitFlow\v1.yml and
    • src\GitVersion.Core\Configuration\SupportedWorkflows\GitHubFlow\v1.yml
  • Change documentation in md files and document the breaking change in BREAKING_CHANGES.md
  • Write integration tests to ensure the feature

image

@CasperWSchmidt CasperWSchmidt changed the title Support Regex for tags property Support Regex for label property Sep 13, 2023
@HHobeck HHobeck closed this as completed Sep 29, 2023
@HHobeck HHobeck linked a pull request Sep 29, 2023 that will close this issue
5 tasks
@arturcic arturcic modified the milestones: 6.x, 6.0.0-beta.4 Dec 12, 2023
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0-beta.4 🎉
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.

4 participants