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

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

Open
2 tasks done
BenB196 opened this issue May 9, 2024 · 2 comments
Open
2 tasks done
Labels

Comments

@BenB196
Copy link

BenB196 commented May 9, 2024

Prerequisites

  • I have written a descriptive issue title
  • 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

@HHobeck
Copy link
Contributor

HHobeck commented May 13, 2024

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

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 HHobeck added this to the 7.x milestone May 13, 2024
@HHobeck
Copy link
Contributor

HHobeck commented May 13, 2024

@asbjornu please confirm

@HHobeck HHobeck removed this from the 7.x milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants