-
Notifications
You must be signed in to change notification settings - Fork 663
Description
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.5.0
Operating system
Linux
What are you seeing?
Description:
GitVersion is throwing a BugException during repository normalization in GitLab CI, claiming that HEAD has moved after the EnsureLocalBranchExistsForCurrentBranch step. This occurs even with full git history available (not shallow clone).
Environment:
GitVersion Version: 6.5.0
Build Environment: GitLab CI
Git Repository: Private enterprise GitLab instance
Operating System: Linux (GitLab CI runner)
GitLab CI Git Configuration:
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 0 # Full clone, not shallow
Error Message:
INFO [25-11-07 8:09:09:49] Applicable build agent found: 'GitLabCi'.
INFO [25-11-07 8:09:09:55] Working directory: /builds/digital-health-services/observability/source-code/cofv1/infra-automation
INFO [25-11-07 8:09:09:57] Project root is: /builds/digital-health-services/observability/source-code/cofv1/infra-automation/
INFO [25-11-07 8:09:09:57] DotGit directory is: /builds/digital-health-services/observability/source-code/cofv1/infra-automation/.git
INFO [25-11-07 8:09:09:57] Branch from build environment: vin-auto
INFO [25-11-07 8:09:09:57] -< Begin: Normalizing git directory for branch 'vin-auto' >-
INFO [25-11-07 8:09:09:61] One remote found (origin -> 'https://gitlab-ci-token:*******@gitlab.apps./digital-health-services/observability/source-code/cofv1/infra-automation.git').
INFO [25-11-07 8:09:09:61] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [25-11-07 8:09:09:62] Creating local branch vin-auto pointing at d16d7ec
INFO [25-11-07 8:09:09:66] -< End: Normalizing git directory for branch 'vin-auto' (Took: 75.38ms) >-
ERROR [25-11-07 8:09:09:68] An unexpected error occurred:
GitVersion.BugException:
GitVersion has a bug, your HEAD has moved after repo normalisation after step 'EnsureLocalBranchExistsForCurrentBranch'
To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
Please run git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100 and submit it along with your build log (with personal info removed) in a new issue at https://github.com/GitTools/GitVersion
at GitVersion.GitPreparer.EnsureRepositoryHeadDuringNormalisation(String occasion, String expectedSha) in //src/GitVersion.Core/Core/GitPreparer.cs:line 206
at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in //src/GitVersion.Core/Core/GitPreparer.cs:line 167
at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in //src/GitVersion.Core/Core/GitPreparer.cs:line 137
at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in //src/GitVersion.Core/Core/GitPreparer.cs:line 68
at GitVersion.GitPreparer.Prepare() in //src/GitVersion.Core/Core/GitPreparer.cs:line 47
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in //src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 68
INFO [25-11-07 8:09:09:68] Please run git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* to see the git graph. This can help you troubleshoot any issues.
What is expected?
Expected Behavior:
With full git history available, GitVersion should successfully normalize the repository without HEAD movement issues.
Steps to Reproduce
GitVersion.yml
` mode: ContinuousDeployment
strategies:
- Mainline
branches:
develop:
mode: ContinuousDelivery
feature:
mode: ContinuousDelivery
hotfix:
mode: ContinuousDelivery
release:
mode: ContinuousDelivery
support:
mode: ContinuousDelivery
unknown:
mode: ContinuousDelivery`
used above gitversion.yml with image of : gittools/gitversion:6.5.0
with variables:
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 0 # Full clone, not shallow
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
INFO [25-11-07 8:09:09:49] Applicable build agent found: 'GitLabCi'.
INFO [25-11-07 8:09:09:55] Working directory: /builds/digital-health-services/observability/source-code/cofv1/infra-automation
INFO [25-11-07 8:09:09:57] Project root is: /builds/digital-health-services/observability/source-code/cofv1/infra-automation/
INFO [25-11-07 8:09:09:57] DotGit directory is: /builds/digital-health-services/observability/source-code/cofv1/infra-automation/.git
INFO [25-11-07 8:09:09:57] Branch from build environment: vin-auto
INFO [25-11-07 8:09:09:57] -< Begin: Normalizing git directory for branch 'vin-auto' >-
INFO [25-11-07 8:09:09:61] One remote found (origin -> 'https://gitlab-ci-token:*******@gitlab.apps..net/digital-health-services/observability/source-code/cofv1/infra-automation.git').
INFO [25-11-07 8:09:09:61] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [25-11-07 8:09:09:62] Creating local branch vin-auto pointing at d16d7ec
INFO [25-11-07 8:09:09:66] -< End: Normalizing git directory for branch 'vin-auto' (Took: 75.38ms) >-
ERROR [25-11-07 8:09:09:68] An unexpected error occurred:
GitVersion.BugException:
GitVersion has a bug, your HEAD has moved after repo normalisation after step 'EnsureLocalBranchExistsForCurrentBranch'
To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100` and submit it along with your build log (with personal info removed) in a new issue at https://github.com/GitTools/GitVersion
at GitVersion.GitPreparer.EnsureRepositoryHeadDuringNormalisation(String occasion, String expectedSha) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 206
at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 167
at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 137
at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 68
at GitVersion.GitPreparer.Prepare() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 47
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 68
INFO [25-11-07 8:09:09:68] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.