Skip to content

fix add normalization for git describe compiler versions#46030

Merged
mnkiefer merged 1 commit into
mainfrom
fix-semver-check-fail
Jul 16, 2026
Merged

fix add normalization for git describe compiler versions#46030
mnkiefer merged 1 commit into
mainfrom
fix-semver-check-fail

Conversation

@mnkiefer

@mnkiefer mnkiefer commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes a false min-version failure when gh-aw is built from a non-tagged local commit. In that case, git describe produces a version like v1.0.0-27-g117acb7f9c, which is semantically older than v1.0.0 under standard semver prerelease ordering, causing the min-version check to incorrectly reject a compatible compiler.

Changes

pkg/semverutil/semverutil.go

  • Added gitDescribePrereleaseRegex to match git-describe prerelease patterns (<N>-g<hash> and <N>-g<hash>-dirty).
  • Added NormalizeGitDescribeSemver(v string) string which strips git-describe-style and dirty prerelease suffixes, collapsing the version to its base release tag.
    • v1.2.3-27-gabc1234v1.2.3
    • v1.2.3-27-gabc1234-dirtyv1.2.3
    • v1.2.3-dirtyv1.2.3
    • v1.2.3-beta.1v1.2.3-beta.1 (real prerelease preserved)

pkg/cli/add_package_manifest.go

  • After validating currentVersion is a valid semver, normalizes it with semverutil.NormalizeGitDescribeSemver before comparing against manifest.MinVersion.

Tests

  • pkg/semverutil/semverutil_test.go: TestNormalizeGitDescribeSemver — 5 table-driven cases covering clean tag, git-describe output, dirty, git-describe+dirty, and real prerelease.
  • pkg/cli/add_package_manifest_test.go: new case verifying that a compiler version of v1.0.0-27-g117acb7f9c satisfies min-version: v1.0.0.

Risk

Low. Normalisation applies only to the in-memory compiler version string during manifest min-version checks. No stored data, API surface, or other comparisons are affected. Real prerelease labels are preserved.

Generated by PR Description Updater for #46030 · 32.1 AIC · ⌖ 4.64 AIC · ⊞ 4.7K ·

@mnkiefer mnkiefer self-assigned this Jul 16, 2026
@mnkiefer
mnkiefer marked this pull request as ready for review July 16, 2026 15:37
Copilot AI review requested due to automatic review settings July 16, 2026 15:37
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #46030 does not have the 'implementation' label and has ≤100 new lines of code in business logic directories (99 additions detected, threshold is 100).

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Normalizes local git describe compiler versions for package manifest compatibility checks while preserving true prerelease semantics.

Changes:

  • Added git describe semantic-version normalization.
  • Applied normalization to manifest min-version checks.
  • Added unit and package-resolution regression tests.
Show a summary per file
File Description
pkg/semverutil/semverutil.go Adds version normalization helper.
pkg/semverutil/semverutil_test.go Tests normalization behavior.
pkg/cli/add_package_manifest.go Normalizes compiler versions before comparison.
pkg/cli/add_package_manifest_test.go Tests manifest resolution with local versions.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Medium

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Clean fix. The regex correctly targets git-describe prerelease patterns, normalization is safely gated behind the existing IsValid check, and the test coverage is thorough. LGTM.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 13.8 AIC · ⌖ 4.25 AIC · ⊞ 5K

@github-actions github-actions Bot mentioned this pull request Jul 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 80/100 — Excellent

Analyzed 2 test(s): 2 design, 0 implementation, 0 violation(s).

📊 Metrics (2 tests)
Metric Value
Analyzed 2 (Go: 2, JS: 0)
✅ Design 2 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 2 (100%)
Duplicate clusters 0
Inflation 1 test (add_package_manifest: 31:1, but justified for integration)
🚨 Violations 0
Test File Classification Issues
TestNormalizeGitDescribeSemver (5 cases) semverutil_test.go:190–231 design_test, table-driven None
"accepts git describe compiler version for matching min-version" add_package_manifest_test.go:380–409 design_test, integration None

Verdict

Passed. 0% implementation tests (threshold: 30%). All tests verify behavioral contracts with edge-case coverage. Both tests have proper error handling and appropriate mocking (external I/O only). The integration test's 31:1 line ratio is justified by the complexity of setup needed to validate the contract.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 11.7 AIC · ⌖ 9.4 AIC · ⊞ 6.8K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Test Quality Sentinel: 80/100. 0% implementation tests (threshold: 30%). All tests verify behavioral contracts with comprehensive edge-case coverage. Both table-driven and integration tests are well-structured with appropriate mocking.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — this is a clean, well-reasoned fix with good regression coverage.

📋 Key Themes & Highlights

Key Themes

  • Root cause properly addressed: The bug is fixed at the right level — normalizing before comparison rather than hacking the comparison itself.
  • Edge case handling: The regex correctly distinguishes git-describe noise (27-gabc1234[-dirty]) from real semver prereleases (beta.1), and the dirty-only case is handled separately.
  • One minor concern: The prerelease regex ^[0-9]+-g[0-9a-f]+(?:-dirty)?$ could silently strip a manually created tag like v1.2.3-1-gdeadbeef that happens to match the git-describe pattern. In practice this is very unlikely, but worth a brief comment in the code noting the tradeoff.

Positive Highlights

  • ✅ Normalization applied after IsValid so invalid inputs are already rejected before reaching NormalizeGitDescribeSemver
  • ✅ Unit tests cover all meaningful cases: clean tag, post-tag, dirty, post-tag+dirty, and real prerelease
  • ✅ Integration test validates the full manifest resolution path, not just the helper in isolation
  • ✅ Minimal call-site change (one line) with clear intent

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 22.5 AIC · ⌖ 5.28 AIC · ⊞ 6.7K
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Non-blocking observations

The core fix is correct: properly collapses git-describe prerelease suffixes before the semver comparison, and the regex correctly distinguishes real git-describe patterns from legitimate semver prereleases like beta.1.

Two minor issues flagged inline:

Findings summary
  • Regex hash length (pkg/semverutil/semverutil.go): g[0-9a-f]+ matches single-char hashes; should be {7,} to reflect real git abbreviated SHA minimums.
  • Fragile test cleanup (add_package_manifest_test.go): t.Cleanup restores to hardcoded "v1.2.3" instead of capturing and restoring the pre-subtest value.

Neither is blocking merge.

🔎 Code quality review by PR Code Quality Reviewer · 56.1 AIC · ⌖ 4.54 AIC · ⊞ 5.6K
Comment /review to run again

Comments that could not be inline-anchored

pkg/cli/add_package_manifest_test.go:388

Fragile cleanup: restores to hardcoded &quot;v1.2.3&quot; instead of the pre-test value — if test ordering or a prior sibling subtest's cleanup changes the baseline, this silently sets the wrong version for subsequent subtests.

<details>
<summary>💡 Suggested fix</summary>

Capture the current version at subtest entry and restore it:

t.Run(&quot;accepts git describe compiler version for matching min-version&quot;, func(t *testing.T) {
    originalVersion := currentVersionForTest() // or however you r…

</details>

<details><summary>pkg/semverutil/semverutil.go:62</summary>

**Regex `g[0-9a-f]+` matches single-char hashesreal git abbreviated SHAs are at least 7 chars.** A prerelease like `1-ga` would be incorrectly treated as a git-describe suffix and silently stripped.

&lt;details&gt;
&lt;summary&gt;💡 Suggested fix&lt;/summary&gt;

Require at least 7 hex characters after `g` to match real abbreviated SHAs:

```go
var gitDescribePrereleaseRegex = regexp.MustCompile(`^\[0-9\]+-g\[0-9a-f\]{7,}(?:-dirty)?$`)

This prevents false-positive matches on short or contrived prereleas…

@mnkiefer
mnkiefer merged commit a56a3e4 into main Jul 16, 2026
81 of 93 checks passed
@mnkiefer
mnkiefer deleted the fix-semver-check-fail branch July 16, 2026 16:00
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.82.11

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.

2 participants