Skip to content

Fix normalization of GitHub Actions historical tag builds - #5198

Open
arturcic wants to merge 1 commit into
GitTools:mainfrom
arturcic:codex/fix-4212-github-tag-normalization
Open

Fix normalization of GitHub Actions historical tag builds#5198
arturcic wants to merge 1 commit into
GitTools:mainfrom
arturcic:codex/fix-4212-github-tag-normalization

Conversation

@arturcic

@arturcic arturcic commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

Fix GitHub Actions builds of historical release tags attempting remote PR-reference discovery during normalization. The build agent now reports the explicitly selected tag separately from branch context. When no local branch identifies HEAD, normalization resolves only that tag and preserves the detached checkout if its commit matches HEAD.

Related Issue

Resolves #4212

Motivation and Context

A tag build can have no branch tip at its commit. Previously this triggered remote-reference discovery even with fetching disabled, causing authentication failures. The selected tag supplies the necessary local information while preserving branch selection and PR discovery for missing or mismatched tag context. Unrelated tags are not dereferenced.

How Has This Been Tested?

  • All 30 remote-repository scenarios passed with both managed and libgit2 backends.
  • All 98 build-agent tests passed.
  • Full solution build passed with zero warnings/errors; formatting verification passed.
  • Regression cases cover lightweight/annotated release tags, multiple tags, unrelated tree/blob tags, packed refs, branch selection, and absent/missing/mismatched build tags.
  • CLI reproduction returned 1.2.3 on both backends with normalization enabled.

CI passed on the final commit, including both Git backends on Windows, Linux, and macOS. All seven GitHub workflows passed, and Sonar reports a passing quality gate with zero open issues.

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copilot AI lite review requested due to automatic review settings September 9, 2026 16:15

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@arturcic
arturcic force-pushed the codex/fix-4212-github-tag-normalization branch from e5d9a09 to 9032f04 Compare September 9, 2026 16:19
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

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.

🟡 Changes recommended

The new GitPreparer tag-match condition can throw when the selected tag does not peel to a commit (e.g., tree/blob tags), which would reintroduce normalization crashes for some tag builds.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/GitVersion.Core/Core/GitPreparer.cs
Copilot AI review requested due to automatic review settings September 9, 2026 16:21

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

🔵 Needs a closer look

The new tag-match path can throw for build-selected tags that do not peel to a commit (e.g., tree/blob tags), which would abort normalization instead of falling back to existing handling.

Review details

Suppressed comments (1)

src/GitVersion.Core/Core/GitPreparer.cs:269

  • ITag.Commit throws when the tag does not peel to a commit (e.g., tree/blob tags). If the build-selected tag (currentTag) ever points at a non-commit object, the ?.Commit.Sha access will raise ArgumentNullException and abort normalization instead of falling back to the existing fake-branch / PR-discovery path.
                    var currentTag = this.buildAgent.GetCurrentTag();
                    if (currentBranchName.IsNullOrEmpty() && currentTag != null
                        && this.repository.Tags.FirstOrDefault(tag => tag.Name.Canonical == currentTag)?.Commit.Sha == headSha)
                    {
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@arturcic

arturcic commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@asbjornu mind to check this one? it's a fix for a bug you opened

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.

[ISSUE]: GitVersion crashes in GitHub Actions when an action is dispatched on a tag

2 participants