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

Compiling projects with GitVersionTask (5.0.1) is incredibly slow on detached head #1868

Closed
mzanin opened this issue Oct 24, 2019 · 7 comments
Labels

Comments

@mzanin
Copy link

mzanin commented Oct 24, 2019

Perhaps related to #694

Compiling a solution with 20+ projects all referencing the GitVersionTask nuget package basically never completes due to GitVersion taking so long.
This is the exception produced by GitVersion:

GitVersionTask.targets(10, 9):   WARN [10/24/19 11:15:01:04] Could not determine assembly version: GitVersion.WarningException: It looks like the branch being examined is a detached Head pointing to commit 'b1008a6'. Without a proper branch name GitVersion cannot determine the build version.
   at GitVersion.GitVersionFinder.EnsureHeadIsNotDetached(GitVersionContext context) in D:\a\1\s\src\GitVersionCore\GitVersionFinder.cs:line 43
   at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context) in D:\a\1\s\src\GitVersionCore\GitVersionFinder.cs:line 16
   at GitVersion.ExecuteCore.<>c__DisplayClass7_0.<ExecuteInternal>b__0(IRepository repo) in D:\a\1\s\src\GitVersionCore\ExecuteCore.cs:line 111
   at GitVersion.GitPreparer.WithRepository[TResult](Func`2 action) in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 92
   at GitVersion.ExecuteCore.ExecuteInternal(String targetBranch, String commitId, GitPreparer gitPreparer, IBuildServer buildServer, Config overrideConfig) in D:\a\1\s\src\GitVersionCore\ExecuteCore.cs:line 108
   at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId, Config overrideConfig, Boolean noCache) in D:\a\1\s\src\GitVersionCore\ExecuteCore.cs:line 55
   at GitVersion.ExecuteCore.TryGetVersion(String directory, VersionVariables& versionVariables, Boolean noFetch, Authentication authentication) in D:\a\1\s\src\GitVersionCore\ExecuteCore.cs:line 79

GitVersion.exe took 10 seconds or so to execute which is also much longer than usual and no version number was computed....

Is there a way to configure this behaviour? This is my GitVersion.yml:

mode: ContinuousDelivery
assembly-versioning-scheme: MajorMinor
assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}'
assembly-informational-format: '{SemVer} {ShortSha}'
increment: None
branches:
  master:
    mode: ContinuousDelivery
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
ignore:
  sha: []
@stale
Copy link

stale bot commented Jan 22, 2020

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 Jan 22, 2020
@asbjornu asbjornu removed the stale label Jan 22, 2020
@asbjornu
Copy link
Member

I would try to figure out why your repository is in a detached HEAD state in the first place. Is that intentional? If not, fix that first. GitVersion needs to know which branch is being built in order to version it correctly. You may also find the discussion in #1850 interesting.

@mzanin
Copy link
Author

mzanin commented Jan 23, 2020

I would try to figure out why your repository is in a detached HEAD state in the first place. Is that intentional?

Sometimes developers just checkout a remote branch (without creating a local branch) for testing, or reviewing etc. so versioning in this instance is not critical. However the GitVersion behavior I described in the summary is definitely less than ideal.

@asbjornu
Copy link
Member

As far as I can understand, it is not a design-goal of GitVersion to work on detached HEAD commits. Without knowing which branch is being built, GitVersion has no meaningful, preditctable way of calculating a verison number.

@mzanin
Copy link
Author

mzanin commented Jan 27, 2020

The issue is not that it isn't producing a valid version number - it's that it is taking an inordinate amount of time, which is a bit inconvenient to say the least. You already remarked on this point in the linked issue:

EnsureHeadIsNotDetached() is throwing, but it's still taking ages to get to the point where the detached head check is being performed.

Which sounds to me like something that could be resolved.

@asbjornu
Copy link
Member

I agree it both should and could be resolved, but my point is that both ensuring detached HEAD commits are resolved quickly as well as producing a meaningful version number for them are out of scope for GitVersion, since detached HEAD commits are unsupported altogether. If you have ideas on how to fail faster on detached HEAD commits, I would warmly welcome a pull request. 🙏

@stale
Copy link

stale bot commented Apr 26, 2020

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 Apr 26, 2020
@stale stale bot closed this as completed May 26, 2020
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

2 participants