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

Cannot get version of a tagged detached head #1501

Closed
lorisp1 opened this issue Oct 16, 2018 · 8 comments
Closed

Cannot get version of a tagged detached head #1501

lorisp1 opened this issue Oct 16, 2018 · 8 comments
Labels

Comments

@lorisp1
Copy link

lorisp1 commented Oct 16, 2018

Hi, I'm new to Gitversion, and I'm doing some experiments to understand how to possibly use it within my company.
I have a POC git repository, using GitFlow. This repository has some branches and some tags:
image
While checking out tag 0.1.1 and running gitversion command line produced the expected output (FullSemVer is "0.1.1", as the tag says), checking out tag 0.1.0 produces an error message, containing the following text:

INFO [10/16/18 8:53:52:82] End: Attempting to inherit branch configuration from parent branch (Took: 97.94ms)
INFO [10/16/18 8:53:52:85] Running against branch: (no branch) (194bc9cfcd989f95357070a7350439d9f3b172d8)
INFO [10/16/18 8:53:52:86] Current commit is tagged with version 0.1.0, version calcuation is for metadata only.
ERROR [10/16/18 8:53:52:86] An unexpected error occurred:
GitTools.WarningException: It looks like the branch being examined is a detached Head pointing to commit '194bc9c'. Without a proper branch name GitVersion cannot determine the build version.
at GitVersion.GitVersionFinder.EnsureHeadIsNotDetached(GitVersionContext context)
at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
at GitVersion.ExecuteCore.<>c__DisplayClass6_0.b__0(IRepository repo)
at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
INFO [10/16/18 8:53:52:86]
INFO [10/16/18 8:53:52:86] Attempting to show the current git graph (please include in issue):
INFO [10/16/18 8:53:52:86] Showing max of 100 commits
INFO [10/16/18 8:53:52:95] * b7328c5 15 hours ago (origin/develop, develop)

If I run git describe on the same checkout, it returns "0.1.0".

From the documentation, I understood that, if a commit is tagged, that tag will always correspond to the returned version, in order to be able to go back to that tag and always have the same version returned by gitversion. Am I missing something?

@josesimoes
Copy link

I believe I'm running into the same problem here. Everything seems to be OK, except when trying to get version on a tag. You can take a look at these build logs from AppVeyor, pretty much the same as the above:
https://ci.appveyor.com/project/nfbot/lib-nanoframework-hardware-stm32/builds/20052090
https://ci.appveyor.com/project/nfbot/lib-nanoframework-hardware-stm32/builds/19947310

@giulianofavro-inpeco
Copy link

giulianofavro-inpeco commented Jan 29, 2019

I belive we have same problem, here after the error log:

>MSBUILD : warning : WARN [01/29/19 15:34:09:96] Could not determine assembly version: GitTools.WarningException: It looks like the branch being examined is a detached Head pointing to commit 'fb8a424'. Without a proper branch name GitVersion cannot determine the build version.
1>MSBUILD : warning :    at GitVersion.GitVersionFinder.EnsureHeadIsNotDetached(GitVersionContext context)
1>MSBUILD : warning :    at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
1>MSBUILD : warning :    at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>b__0(IRepository repo)
1>MSBUILD : warning :    at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action)
1>MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteInternal(String targetBranch, String commitId, GitPreparer gitPreparer, IBuildServer buildServer, Config overrideConfig)
1>MSBUILD : warning :    at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache)
1>MSBUILD : warning :    at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication)

@stale
Copy link

stale bot commented Jun 29, 2019

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 Jun 29, 2019
@stale stale bot closed this as completed Jul 29, 2019
@zionyx
Copy link

zionyx commented Jan 20, 2020

Stale bot, shoo. It's a valid use case, we like this use case to be supported. 🙏

@asbjornu
Copy link
Member

As none of the current maintainers of GitVersion have a need for versioning detached head commits themselves, you can't expect us to implement support for this. However, a pull request adding support for this would be happily merged. Such a pull request would coincidentally fix #2753.

@asbjornu asbjornu reopened this Jul 16, 2021
@stale stale bot removed the stale label Jul 16, 2021
@Evangelink
Copy link
Contributor

@asbjornu That's not a coincidence :) I was actually starting to do some work for #2697 and in the process I decided to create related issues :D

@Evangelink
Copy link
Contributor

Just posting a simple workaround for people who didn't think of it but if you simply create a branch out of this detached head (commit in history) then everything works properly.

@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
@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants