question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Improvement] Better error message when in detached head

See original GitHub issue

Is your improvement request related to a problem? Please describe.

When re-building a commit in history, I often fail to remember to comment the GitVersion.MsBuild package reference from my project. Which results in one failure per project with the following message:

Severity	Code	Description	Project	File	Line	Suppression State
Error	MSB3073	The command ""C:\Users\XXX\.nuget\packages\gitversion.msbuild\5.6.10\tools\net48/gitversion.exe" "C:\Src\YYY" -output file -outputfile obj\gitversion.json" exited with code 1.	YYY	C:\Users\XXX\.nuget\packages\gitversion.msbuild\5.6.10\tools\GitVersion.MsBuild.targets	9	

This error message is pretty generic and could (maybe?) be improved for the case of detached head with a more helpful message.

Detailed Description

Either return a different exit code and document it and/or fail with a message that would be displayed. I haven’t done msbuild tasks for quite some time and so I don’t really remember what’s possible and how to do so.

Context

Relates to #2697

Possible Implementation

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
Evangelinkcommented, Mar 3, 2022

Hey @asbjornu! I am really sorry about all that delay. I had a pretty busy end of year, I will try to give it a go during the week-end.

0reactions
nenadvicenticcommented, Jul 31, 2023

I just got the same error again with 5.12.0:

  ERROR [07/31/23 12:27:11:55] An unexpected error occurred:
[12:27:11]GitVersion.BugException: GitVersion has a bug, your HEAD has moved after repo normalisation.
[12:27:11]
[12:27:11]To disable this error set an environmental variable called IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1
[12:27:11]
[12:27:11]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
[12:27:11]   at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 192
[12:27:11]   at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
[12:27:11]   at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
[12:27:11]   at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
[12:27:11]   at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
[12:27:11]   at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 66
[12:27:11]Process exited with code 1

When IGNORE_NORMALISATION_GIT_HEAD_MOVE to 1 is added, as recommended here, GitVersion incorrectly picks latest commit and calculates wrong version number of the build.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git Detached Head: What Is It & How to Recover
Git detached head might be a weird error message, but don't despair. Learn what this means and how to fix it!
Read more >
How do I fix a Git detached head?
Detached head means you are no longer on a branch, you have checked out a single commit in the history (in this case...
Read more >
Git detached head: What is it & How to fix it
A git detached HEAD state occurs when you are not on a branch but directly on a specific commit. There are also several...
Read more >
Correcting detached head problems with Git
This detached head state occurs when a specific commit is checked out instead of a branch. You cannot commit to a commit—only to...
Read more >
Recovering from the Git detached HEAD state
With these simple steps, you have successfully preserved your changes and recovered from the Git detached HEAD state.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found