GitVersion: GitVersion has a bug, your HEAD has moved after repo normalisation.
We have a peculiar issue that keeps happening on one specific commit, that is not at the tip of our branch. The latest commit in this branch does not exhibit the issue (so we’re past it). I’m creating this issue because it might show some other problem you guys have (and because the exception told me to).
$ --- equivalent of dotnet-gitversion ---
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.GitRepositoryHelper.NormalizeGitDirectory(String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch)
at GitVersion.GitPreparer.Initialise(Boolean normaliseGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
at BuildLib.Tasks.ArtBuildTasks.DetermineVersionInfo(ChronosBuildBase buildBase) in C:\Project\Builder\BuildTasks.cs:line 27
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at BuildLib.Bases.ChronosBuildBase.<get_GenerateVersionInfo>b__40_1() in C:\Project\Builder\BuildBase.cs:line 118
at System.Collections.Generic.List`1.ForEach(Action`1 action)
at Nuke.Common.Execution.BuildExecutor.Execute(NukeBuild build, IEnumerable`1 executionList)
at Nuke.Common.Execution.BuildExecutor.Execute[T](Expression`1 defaultTargetExpression)
Output of git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=* -n 100: git-152228.txt
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (11 by maintainers)
Commits related to this issue
- Set IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1 as a workaround for https://github.com/GitTools/GitVersion/issues/1627 — committed to ApolonTorq/Torq.Nuke.Retype by ApolonTorq 2 years ago
- Set IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1 as a workaround for https://github.com/GitTools/GitVersion/issues/1627 — committed to ApolonTorq/Torq.Nuke.Retype by ApolonTorq 2 years ago
- - adds trouble shooting information for https://github.com/GitTools/GitVersion/issues/1627 — committed to rominator1983/GitVersion by rominator1983 2 years ago
- - adds trouble shooting information for https://github.com/GitTools/GitVersion/issues/1627 — committed to rominator1983/GitVersion by rominator1983 2 years ago
- - adds trouble shooting information for https://github.com/GitTools/GitVersion/issues/1627 — committed to rominator1983/GitVersion by rominator1983 2 years ago
- - adds trouble shooting information for https://github.com/GitTools/GitVersion/issues/1627 — committed to rominator1983/GitVersion by rominator1983 2 years ago
- Merge pull request #3245 from rominator1983/addTroubleshootingInformationForNormalisationBug Adds trouble shooting info for #1627 — committed to GitTools/GitVersion by arturcic a year ago
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. Thank you for your contributions.
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. Thank you for your contributions.
To clarify: The above means that a
git statuswill showdetached head.@rominator1983 please create a PR and there we can check and discuss
We are getting this a LOT on Teamcity. First I thought it might be just for history builds (where the tip of branch has moved on the remote) as is described in the initial issue post. Since we are using the flag ‘teamcity.git.fetchAllHeads’ I think the bug could be caused by the flag for history builds.
But I have seen several occasions of this exception happening on one agent for the most recent main-commit (tip) and not happening on most other agents for the exact same commit which was always the tip of main.
So the question for me is how to tackle and track down the bug since it is becoming a huge problem in our build pipeline.
We could narrow down what causes the bug in the repo normalisation by checking for the commit-hash after each and every step during the normalisation. This would be for troubleshooting only and should be implemented so that it does not break any other behavior. What are your thoughts on that? Would you accept such a PR?