question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Allow named captures in regex to be used in tag names

See original GitHub issue

Is your feature request related to a problem? Please describe. I’m managing a product and I want to be able to release explicit alpha, beta and rc builds depending on the branch name. Right now I have to create multiple branch configs with regex’s to match the branch suffixes, but I thought it could be cool if GitVersion was able to do named captures and then allow those names to be used in the tag format, similar to how you have {BranchName} currently.

Detailed Description

How this could look is in a branch config, you could have something like

branches:
    release:
        regex: ^releases?[/-].*?(-(?<regexsuffix>.*))?$
        tag: {regexsuffix || 'rc'}

So in this example, it attempts to match a suffix on the branch name such as -alpha$ or -beta$ and then exposes that as a regexsuffix variable in the tag format. An extra step in the tag format I’ve envisioned here is to be able to support a fallback, so if there is no named group capture, then fallback to the string value rc.

Context

This would ultimately allow for dynamic configuration of a branch’s tag so that you wouldn’t always need multiple configurations if they are ultimately the same apart from the regex / tag config.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
arturciccommented, Aug 17, 2021

I would rename the tests into integration in the root, and create a src\tests and move there the tests projects, but keep them in the main solution

1reaction
mattbrailsfordcommented, Aug 17, 2021

@asbjornu cool, I think that’s something I should be able to do 👍.

Do you have an example of how you need the tests written. The tests folder is a little empty so can’t fully work out how you are doing them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Named Capturing Groups and Backreferences
Python's re module was the first to offer a solution: named capturing groups and named backreferences. (?P<name>group) captures the match of group into...
Read more >
Javascript: Named Capture Groups - regex
Now, with ES2018, RegExp named capture groups are actually possible. ... regex features missing from JS regex, such as lookbehinds.
Read more >
Named capturing group: (?<name>...) - MDN Web Docs - Mozilla
A named capturing group is a particular kind of capturing group that allows to give a name to the group. The group's matching...
Read more >
Using Named Groups for Tagging
To create a named group in a Python regular expression, instead of using plain parentheses to surround the group, use parentheses of the...
Read more >
Capturing groups
Capturing groups · It allows to get a part of the match as a separate item in the result array. · If we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found