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

[Bug] GitVersion has a bug, your HEAD has moved after repo normalisation #3495

Closed
DmitriyMaksimov opened this issue Apr 27, 2023 · 6 comments

Comments

@DmitriyMaksimov
Copy link

Describe the bug
GitVersion.BugException: GitVersion has a bug, your HEAD has moved after repo normalisation
Full log:

>dotnet-gitversion /output buildserver /verbosity minimal 
  ERROR [04/27/23 23:30:15:26] An unexpected error occurred:
GitVersion.BugException: GitVersion has a bug, your HEAD has moved after repo normalisation.

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.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 192
   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
   at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
INFO [04/27/23 23:30:05:82] Applicable build agent found: 'Jenkins'.
  ERROR [04/27/23 23:30:15:26] An unexpected error occurred:
GitVersion.BugException: GitVersion has a bug, your HEAD has moved after repo normalisation.

Expected Behavior

The "HEAD has moved after repo normalisation" should be handled gracefully.

Actual Behavior

The above exception thrown.
We set "IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1" for PR (feature branch) builds, but for main branch we don't want to use the workaround.

Possible Fix

Steps to Reproduce

The error description asking for output of the git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100. Please find the output attached.

Context

As the result of the failure, our CI builds are failing.

Your Environment

Windows builds on Jenkins.

  • Version Used:
  • Operating System Windows Server 2019
@DmitriyMaksimov
Copy link
Author

@michael-g-matthews
Copy link

I am also seeing this but with GitLab CI for Merge Request Pipelines only (basic pipelines for commits work as expected)

The pipeline runner is running inside Docker for Ubuntu 22.04 LTS with the docker image: gittools/gitversion.

A copy of the job instructions (based on the GitVersion - GitLab CI tutorial), git log output, and the CI job log are attached

GitLab-CI-JobLog.txt
gitversion_error_gitlog.txt
gitlab-ci.yml.txt

Following the instructions in the tutorial, Enable merged results pipelines has been disabled, and Enable "Delete source branch" option by default has been enabled.

Setting IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1 does allow the job to succeed but I would rather not use the workaround if possible.

@ashek-simeon
Copy link

For anyone encountering this GitVersion.BugException using GitHub Actions, this adjustment to the checkout step resolved the issue for me:

actions/checkout#124 (comment)

@batzen
Copy link
Contributor

batzen commented Aug 1, 2023

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.

@github-actions github-actions bot added the stale label Oct 31, 2023
Copy link

This issue was closed because it has been stalled for 30 days with no activity. Thank you for your contributions

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants