GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

[ISSUE]: Regex Capture Groups don't work correctly on release branch.

Open BenB196 opened this issue 2 years ago • 4 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

6.0.0-beta.7-alpine.3.18-7.0

Operating system

Linux

What are you seeing?

I am seeing GitVersion not properly do regex capture grouping and returning invalid versions/labels.

Example:

GitVersion_SemVer=0.2.0-beta{SubBranchName}.1
GitVersion_FullSemVer=0.2.0-beta{SubBranchName}.1+0

What is expected?

I would expect {SubBranchName} to be a proper value:

Example:

GitVersion_SemVer=0.2.0-beta-bravo.1
GitVersion_FullSemVer=0.2.0-beta-bravo.1+0

Steps to Reproduce

  1. Use a default GitVersion.yml set to mode: ContinuousDelivery
  2. Update the release branch configuration to look like:
release:
  regex: ^releases?[/-]\d+(?:.\d+)?(?:.\d+)(?<SubBranchName>.*)
  label: 'beta{SubBranchName}'
  1. Run GitVersion against a branch named release/0.2.0 Observe the correct output:
GitVersion_SemVer=0.2.0-beta.1
  1. Run GitVersion against a branch named release/0.2.0-bravo Observe the incorrect output:
GitVersion_SemVer=0.2.0-beta{SubBranchName}.1

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

BenB196 avatar May 09 '24 01:05 BenB196

The functionality to "Support Regex for label property" was implemented in this PR:

  • https://github.com/GitTools/GitVersion/pull/3687

I agree that the behavior you are describing here is not intuitive. If you like please fix this and create a pull request for it:

  • Change the release and hotfix regex in GitFlowConfigurationBuilder and GitHubFlowConfigurationBuilder to support branch name override natively (e.g. label: '({captureGroups.SubBranchName} ?? "beta").ToLower()')
  • Change the workflow resources in src\GitVersion.Configuration\Workflows
  • Remove branchNameOverride parameter in ConfigurationExtensions::GetBranchSpecificLabel
  • Change the logic in GetBranchSpecificLabel and use dynamic string interpolation
  • Create integration tests

image

HHobeck avatar May 13 '24 06:05 HHobeck

@asbjornu please confirm

HHobeck avatar May 13 '24 08:05 HHobeck

Sounds reasonable. As long as no existing tests fail, I'm positive. :)

asbjornu avatar Jun 28 '24 09:06 asbjornu

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.

github-actions[bot] avatar Sep 26 '24 11:09 github-actions[bot]

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

github-actions[bot] avatar Oct 26 '24 11:10 github-actions[bot]