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

[Improvement] Better error message when in detached head #2753

Closed
Evangelink opened this issue Jul 15, 2021 · 11 comments
Closed

[Improvement] Better error message when in detached head #2753

Evangelink opened this issue Jul 15, 2021 · 11 comments
Milestone

Comments

@Evangelink
Copy link
Contributor

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

@asbjornu
Copy link
Member

Improvements in error messages are always welcome! A PR would be highly appreciated. 🙏🏼

@Evangelink
Copy link
Contributor Author

I will try to provide something but if you have some spare time for a couple of advices, they would be welcome :)

@asbjornu
Copy link
Member

If you are able to reproduce the problem with the command line, we can see whether the exception thrown is something sensible and start from there.

@Evangelink
Copy link
Contributor Author

Just for the sake of grouping the info together, here are the steps to reproduce the issue:

  • Install GitVersion on a project
  • Make some commit
  • Checkout previous commit
  • Rebuild solution
  • Build fail with error saying gitversion.exe failed

@stale
Copy link

stale bot commented Mar 2, 2022

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.

@stale stale bot added the stale label Mar 2, 2022
@asbjornu
Copy link
Member

asbjornu commented Mar 2, 2022

A PR that improves the error message of detached heads is still very welcome. :)

@stale stale bot removed the stale label Mar 2, 2022
@Evangelink
Copy link
Contributor Author

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.

@asbjornu
Copy link
Member

asbjornu commented Mar 3, 2022

No problem, @Evangelink. Take we're in no rush. :)

@asbjornu
Copy link
Member

Fixed by #3338.

@asbjornu asbjornu added this to the 5.x milestone Jan 20, 2023
@arturcic arturcic modified the milestones: 5.x, 5.12.0 Jan 20, 2023
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 5.12.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

@nenadvicentic
Copy link
Contributor

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.

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