Skip to content

GHA-290 Fix get-jira-version to handle SemVer build metadata separator#147

Open
kirill-knize-sonarsource wants to merge 1 commit intomasterfrom
fix/get-jira-version-semver-plus
Open

GHA-290 Fix get-jira-version to handle SemVer build metadata separator#147
kirill-knize-sonarsource wants to merge 1 commit intomasterfrom
fix/get-jira-version-semver-plus

Conversation

@kirill-knize-sonarsource
Copy link
Copy Markdown
Member

No description provided.

@hashicorp-vault-sonar-prod
Copy link
Copy Markdown

hashicorp-vault-sonar-prod Bot commented May 8, 2026

GHA-290

@sonar-review-alpha
Copy link
Copy Markdown
Contributor

sonar-review-alpha Bot commented May 8, 2026

Summary

Fixes SemVer build metadata handling in get-jira-version

The action previously failed to parse version strings containing SemVer build metadata (e.g., 5.2.3+80217). The fix adds an initial cut operation to strip everything after the + separator before extracting the major.minor.patch components.

What changed:

  • Modified the version extraction pipeline to first remove build metadata (+ cut -d '+' -f 1), then extract semantic version components (cut -d '.' -f 1-3)
  • Updated the inline comment to clarify the new behavior

What reviewers should know

For reviewers:

  • The fix is minimal and surgical — only 2 lines changed in a single action file
  • The change is backwards compatible: versions without + metadata pass through unchanged (the first cut returns the whole string when no + is found)
  • The semantic versioning spec supports build metadata via +, so this is a real-world fix, not a theoretical edge case
  • No tests are visible in this diff; check if test coverage for this scenario exists elsewhere in the repo

  • Generate Walkthrough
  • Generate Diagram

🗣️ Give feedback

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

@sonar-review-alpha sonar-review-alpha Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix itself is correct and backward-compatible — stripping + metadata before the dot-split is the right approach, and versions without + pass through unchanged. However, the test workflow wasn't updated alongside the implementation, leaving a stale copy of the old logic and no coverage for the newly supported input format.

Logic duplication / stale test code

.github/workflows/test-get-jira-version.yml line 88 manually reimplements the action's version-parsing logic:

VERSION=$(echo "$RELEASE_VERSION" | cut -d '.' -f 1-3)

This is the old implementation — the cut -d '+' -f 1 strip is missing. The test input (5.6.7.89) happens to have no +, so CI still passes, but the manually-inlined copy now diverges from the actual implementation. If this step is meant to validate that the env var is set correctly, it should either call the action itself (like the other test steps do) or at minimum mirror the current parsing pipeline.

Missing test case for the bug being fixed

None of the existing tests exercise a version string containing + (e.g., 5.2.3+80217). Adding one would confirm the fix works end-to-end and prevent regressions.

🗣️ Give feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant