Description
Prerequisites
- I have written a descriptive issue title
- I have searched issues to ensure it has not already been reported
GitVersion package
GitVersion.Tool
GitVersion version
6.0.2
Operating system
Linux
What are you seeing?
Related to #2074, #2456, #4015, and #4183; when a GitHub Action with on: workflow_dispatch
is manually started in the GitHub UI by building a specific tag, GitVersion crashes:
INFO [24-09-18 9:18:18:90] Working directory: /home/runner/work/…/…
INFO [24-09-18 9:18:19:01] Project root is: /home/runner/work/…/…/
INFO [24-09-18 9:18:19:01] DotGit directory is: /home/runner/work/…/…/.git
INFO [24-09-18 9:18:19:01] Branch from build environment:
INFO [24-09-18 9:18:19:01] -< Begin: Normalizing git directory for branch '' >-
INFO [24-09-18 9:18:19:04] One remote found (origin -> 'https://github.com/…/…').
INFO [24-09-18 9:18:19:04] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [24-09-18 9:18:19:05] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking ….
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/main'.
INFO [24-09-18 9:18:19:08] HEAD is detached and points at commit 'bd0483d972605906d5cc1d748c84c90a485d29ad'.
INFO [24-09-18 9:18:19:08] Local Refs:
refs/tags/1.0 (9da7674a873c8457632f59487e7e2093f2bec198)
refs/tags/1.0.1 (22c0373b037e81fe5c0d2e32758137967f6effef)
refs/tags/1.0.2 (7fe3f4e494dc217a48f75173fb98ff941ca71762)
refs/tags/1.0.3 (531ffd5f142e510459a98e87cab40394de905293)
refs/tags/1.1.0 (a4493a58e04d195afd5b245f4ed1542db10a2b20)
refs/tags/1.1.1 (1f83d282d89f21cd3cccc7e81691dbfa3b5f7e13)
refs/tags/1.1.2 (8f40a679d9a716e10fccfb740d5cf42b4a577309)
refs/tags/1.2.0 (b0d8de7b4935df7baf8775b90195ab27dc577269)
refs/tags/1.2.1 (6c64c08e9a3c6b85ecc8beeca8abcead8077535b)
refs/tags/1.2.10-alpha.1 (ef56c4267258da3d59fecf2dd8aa2cc6a241d211)
refs/tags/1.2.2 (ab0ebf2b533ad268012e43d86bee328b1b4208dc)
refs/tags/1.2.3 (7e29cebb5942ddce12f7ea4e91ddcdfbe3c95016)
refs/tags/1.2.4 (882b731c5ea03907cf96af24c360548d842d8693)
refs/tags/1.2.5 (8738e3fcfb4d115735959db29ad2785175d0b5fe)
refs/tags/1.2.6 (e4e7193a30009fc732be28228510ee5141783348)
refs/tags/1.2.7 (3e63d02b7f664a975a3708329daf3d61c7c7297d)
refs/tags/1.2.8 (9ecfde9650384ed8d75759bca095bf633dc74fe3)
refs/tags/1.2.9 (3196dc0456304004bfb17c7431f6d791524e81a9)
refs/tags/1.3.0 (b7c153855cf46d83271344b3879e5459d82c76d1)
refs/tags/1.3.1 (6c9d0e908f6a788fb6dd46aa218119e0244ebdb6)
refs/tags/1.3.2 (aeaa170909a8cf13ee351c7ebf62f3c02f017ec1)
refs/tags/1.4.0 (ec85de877dbd5af669c0b71b553869456c1bfc44)
refs/tags/1.4.1 (bd0483d972605906d5cc1d748c84c90a485d29ad)
INFO [24-09-18 9:18:19:08] No local branch pointing at the commit 'bd0483d972605906d5cc1d748c84c90a485d29ad'. Fake branch needs to be created.
INFO [24-09-18 9:18:19:09] Fetching remote refs to see if there is a pull request ref
INFO [24-09-18 9:18:19:27] -< End: Normalizing git directory for branch '' (Took: 255.42ms) >-
ERROR [24-09-18 9:18:19:39] An unexpected error occurred:
LibGit2Sharp.LibGit2SharpException: remote authentication required but no callback set
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.git_remote_connect(RemoteHandle remote, GitDirection direction, GitRemoteCallbacks& remoteCallbacks, GitProxyOptions& proxyOptions) in /_/LibGit2Sharp/Core/Proxy.cs:line 2172
at LibGit2Sharp.Network.ListReferencesInternal(String url, CredentialsHandler credentialsProvider, ProxyOptions proxyOptions) in /_/LibGit2Sharp/Network.cs:line 213
at LibGit2Sharp.Network.ListReferences(Remote remote) in /_/LibGit2Sharp/Network.cs:line 55
at GitVersion.Git.GitRepository.GetPullRequestReference(AuthenticationInfo auth, Remote remote, String headTipSha) in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 91
at GitVersion.Git.GitRepository.<>c__DisplayClass33_0.<CreateBranchForPullRequestBranch>b__0() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 61
at GitVersion.Git.RepositoryExtensions.RunSafe(Action operation) in /_/src/GitVersion.LibGit2Sharp/Git/RepositoryExtensions.cs:line 9
at GitVersion.Git.GitRepository.CreateBranchForPullRequestBranch(AuthenticationInfo auth) in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 51
at GitVersion.GitPreparer.<>c__DisplayClass19_0.<EnsureHeadIsAttachedToBranch>b__3() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 241
at GitVersion.Helpers.RetryAction`1.<>c__DisplayClass1_0.<Execute>b__0() in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 11
at Polly.Policy`1.<>c__DisplayClass11_0.<Execute>b__0(Context _, CancellationToken _)
at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider)
at Polly.Retry.RetryPolicy`1.Implementation(Func`3 action, Context context, CancellationToken cancellationToken)
at Polly.Policy`1.Execute(Func`3 action, Context context, CancellationToken cancellationToken)
at Polly.Policy`1.Execute(Func`1 action)
at GitVersion.Helpers.RetryAction`2.Execute(Func`1 operation) in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 30
at GitVersion.Helpers.RetryAction`1.Execute(Action operation) in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 9
at GitVersion.GitPreparer.EnsureHeadIsAttachedToBranch(String currentBranchName, AuthenticationInfo authentication) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 241
at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 181
at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 131
at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 66
at GitVersion.GitPreparer.Prepare() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 45
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 66
INFO [24-09-18 9:18:19:39] Please run `git log --graph --format="%h %cr %d" --decorate --date=relative --all --remotes=*` to see the git graph. This can help you troubleshoot any issues.
INFO [24-09-18 9:18:18:85] Applicable build agent found: 'GitHubActions'.
INFO [24-09-18 9:18:18:90] Working directory: /home/runner/work/explore.ludenso.com/explore.ludenso.com
INFO [24-09-18 9:18:19:01] Project root is: /home/runner/work/explore.ludenso.com/explore.ludenso.com/
INFO [24-09-18 9:18:19:01] DotGit directory is: /home/runner/work/explore.ludenso.com/explore.ludenso.com/.git
INFO [24-09-18 9:18:19:01] Branch from build environment:
INFO [24-09-18 9:18:19:01] -< Begin: Normalizing git directory for branch '' >-
INFO [24-09-18 9:18:19:04] One remote found (origin -> 'https://github.com/Ludenso/explore.ludenso.com').
INFO [24-09-18 9:18:19:04] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
INFO [24-09-18 9:18:19:05] Creating local branch from remote tracking 'refs/remotes/origin/108-move-additional-experience-uids-to-a-separate-json-file'.
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking 'refs/remotes/origin/96-move-away-from-azure-static-web-apps'.
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking 'refs/remotes/origin/98-wcag-22-aa-compliancy'.
INFO [24-09-18 9:18:19:06] Creating local branch from remote tracking 'refs/remotes/origin/dependabot/github_actions/gittools/actions-3.0.0'.
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/dependabot/npm_and_yarn/microsoft/applicationinsights-web-3.3.2'.
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/dependabot/npm_and_yarn/npm_and_yarn-1482e54221'.
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/dependabot/npm_and_yarn/three-0.168.0'.
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/dependabot/npm_and_yarn/tweenjs/tween.js-25.0.0'.
INFO [24-09-18 9:18:19:07] Creating local branch from remote tracking 'refs/remotes/origin/main'.
INFO [24-09-18 9:18:19:08] HEAD is detached and points at commit 'bd0483d972605906d5cc1d748c84c90a485d29ad'.
INFO [24-09-18 9:18:19:08] Local Refs:
refs/heads/108-move-additional-experience-uids-to-a-separate-json-file (90538e2a99266e6e522ee7d831b62f72823a44e5)
refs/heads/96-move-away-from-azure-static-web-apps (820ff19adbd55b75bc1708535002f2276481b1b4)
refs/heads/98-wcag-22-aa-compliancy (7fa7594848f82fae27a91e3e06d21727522df381)
refs/heads/dependabot/github_actions/gittools/actions-3.0.0 (adc806c2dde296c0767ac8f75a0f2d82c429a447)
refs/heads/dependabot/npm_and_yarn/microsoft/applicationinsights-web-3.3.2 (2b659954f812cb72e3336b6882a5f986aae2db13)
refs/heads/dependabot/npm_and_yarn/npm_and_yarn-1482e54221 (2f852568463e9a4446204695893939b8df3fddac)
refs/heads/dependabot/npm_and_yarn/three-0.168.0 (d527cbabfab2be329e8e8e257ce56dbbc33dad1f)
refs/heads/dependabot/npm_and_yarn/tweenjs/tween.js-25.0.0 (b8accd9a2e7e56226024b1ebce1b39c3197aec8b)
refs/heads/main (7a443162ac73655f5e0f57bcccf8224de58a05dc)
refs/remotes/origin/108-move-additional-experience-uids-to-a-separate-json-file (90538e2a99266e6e522ee7d831b62f72823a44e5)
refs/remotes/origin/96-move-away-from-azure-static-web-apps (820ff19adbd55b75bc1708535002f2276481b1b4)
refs/remotes/origin/98-wcag-22-aa-compliancy (7fa7594848f82fae27a91e3e06d21727522df381)
refs/remotes/origin/dependabot/github_actions/gittools/actions-3.0.0 (adc806c2dde296c0767ac8f75a0f2d82c429a447)
refs/remotes/origin/dependabot/npm_and_yarn/microsoft/applicationinsights-web-3.3.2 (2b659954f812cb72e3336b6882a5f986aae2db13)
refs/remotes/origin/dependabot/npm_and_yarn/npm_and_yarn-1482e54221 (2f852568463e9a4446204695893939b8df3fddac)
refs/remotes/origin/dependabot/npm_and_yarn/three-0.168.0 (d527cbabfab2be329e8e8e257ce56dbbc33dad1f)
refs/remotes/origin/dependabot/npm_and_yarn/tweenjs/tween.js-25.0.0 (b8accd9a2e7e56226024b1ebce1b39c3197aec8b)
refs/remotes/origin/main (7a443162ac73655f5e0f57bcccf8224de58a05dc)
refs/tags/1.0 (9da7674a873c8457632f59487e7e2093f2bec198)
refs/tags/1.0.1 (22c0373b037e81fe5c0d2e32758137967f6effef)
refs/tags/1.0.2 (7fe3f4e494dc217a48f75173fb98ff941ca71762)
refs/tags/1.0.3 (531ffd5f142e510459a98e87cab40394de905293)
refs/tags/1.1.0 (a4493a58e04d195afd5b245f4ed1542db10a2b20)
refs/tags/1.1.1 (1f83d282d89f21cd3cccc7e81691dbfa3b5f7e13)
refs/tags/1.1.2 (8f40a679d9a716e10fccfb740d5cf42b4a577309)
refs/tags/1.2.0 (b0d8de7b4935df7baf8775b90195ab27dc577269)
refs/tags/1.2.1 (6c64c08e9a3c6b85ecc8beeca8abcead8077535b)
refs/tags/1.2.10-alpha.1 (ef56c4267258da3d59fecf2dd8aa2cc6a241d211)
refs/tags/1.2.2 (ab0ebf2b533ad268012e43d86bee328b1b4208dc)
refs/tags/1.2.3 (7e29cebb5942ddce12f7ea4e91ddcdfbe3c95016)
refs/tags/1.2.4 (882b731c5ea03907cf96af24c360548d842d8693)
refs/tags/1.2.5 (8738e3fcfb4d115735959db29ad2785175d0b5fe)
refs/tags/1.2.6 (e4e7193a30009fc732be28228510ee5141783348)
refs/tags/1.2.7 (3e63d02b7f664a975a3708329daf3d61c7c7297d)
refs/tags/1.2.8 (9ecfde9650384ed8d75759bca095bf633dc74fe3)
refs/tags/1.2.9 (3196dc0456304004bfb17c7431f6d791524e81a9)
refs/tags/1.3.0 (b7c153855cf46d83271344b3879e5459d82c76d1)
refs/tags/1.3.1 (6c9d0e908f6a788fb6dd46aa218119e0244ebdb6)
refs/tags/1.3.2 (aeaa170909a8cf13ee351c7ebf62f3c02f017ec1)
refs/tags/1.4.0 (ec85de877dbd5af669c0b71b553869456c1bfc44)
refs/tags/1.4.1 (bd0483d972605906d5cc1d748c84c90a485d29ad)
INFO [24-09-18 9:18:19:08] No local branch pointing at the commit 'bd0483d972605906d5cc1d748c84c90a485d29ad'. Fake branch needs to be created.
INFO [24-09-18 9:18:19:09] Fetching remote refs to see if there is a pull request ref
INFO [24-09-18 9:18:19:27] -< End: Normalizing git directory for branch '' (Took: 255.42ms) >-
ERROR [24-09-18 9:18:19:39] An unexpected error occurred:
LibGit2Sharp.LibGit2SharpException: remote authentication required but no callback set
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 154
at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in /_/LibGit2Sharp/Core/Ensure.cs:line 172
at LibGit2Sharp.Core.Proxy.git_remote_connect(RemoteHandle remote, GitDirection direction, GitRemoteCallbacks& remoteCallbacks, GitProxyOptions& proxyOptions) in /_/LibGit2Sharp/Core/Proxy.cs:line 2172
at LibGit2Sharp.Network.ListReferencesInternal(String url, CredentialsHandler credentialsProvider, ProxyOptions proxyOptions) in /_/LibGit2Sharp/Network.cs:line 213
at LibGit2Sharp.Network.ListReferences(Remote remote) in /_/LibGit2Sharp/Network.cs:line 55
at GitVersion.Git.GitRepository.GetPullRequestReference(AuthenticationInfo auth, Remote remote, String headTipSha) in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 91
at GitVersion.Git.GitRepository.<>c__DisplayClass33_0.<CreateBranchForPullRequestBranch>b__0() in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 61
at GitVersion.Git.RepositoryExtensions.RunSafe(Action operation) in /_/src/GitVersion.LibGit2Sharp/Git/RepositoryExtensions.cs:line 9
at GitVersion.Git.GitRepository.CreateBranchForPullRequestBranch(AuthenticationInfo auth) in /_/src/GitVersion.LibGit2Sharp/Git/GitRepository.extended.cs:line 51
at GitVersion.GitPreparer.<>c__DisplayClass19_0.<EnsureHeadIsAttachedToBranch>b__3() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 241
at GitVersion.Helpers.RetryAction`1.<>c__DisplayClass1_0.<Execute>b__0() in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 11
at Polly.Policy`1.<>c__DisplayClass11_0.<Execute>b__0(Context _, CancellationToken _)
at Polly.Retry.RetryEngine.Implementation[TResult](Func`3 action, Context context, CancellationToken cancellationToken, ExceptionPredicates shouldRetryExceptionPredicates, ResultPredicates`1 shouldRetryResultPredicates, Action`4 onRetry, Int32 permittedRetryCount, IEnumerable`1 sleepDurationsEnumerable, Func`4 sleepDurationProvider)
at Polly.Retry.RetryPolicy`1.Implementation(Func`3 action, Context context, CancellationToken cancellationToken)
at Polly.Policy`1.Execute(Func`3 action, Context context, CancellationToken cancellationToken)
at Polly.Policy`1.Execute(Func`1 action)
at GitVersion.Helpers.RetryAction`2.Execute(Func`1 operation) in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 30
at GitVersion.Helpers.RetryAction`1.Execute(Action operation) in /_/src/GitVersion.Core/Helpers/RetryAction.cs:line 9
at GitVersion.GitPreparer.EnsureHeadIsAttachedToBranch(String currentBranchName, AuthenticationInfo authentication) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 241
at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 181
at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 131
at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 66
at GitVersion.GitPreparer.Prepare() in /_/src/GitVersion.Core/Core/GitPreparer.cs:line 45
at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in /_/src/GitVersion.Core/Core/GitVersionCalculateTool.cs:line 35
at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in /_/src/GitVersion.App/GitVersionExecutor.cs:line 66
To fix all of these bugs and crashes, I believe we need to do as I write in #4183 (reply in thread):
I think what GitVersion needs to do is a ref-check of the checked out commit SHA, and if a tag is found matching the branch name, follow the logic as if it was a tagged commit on the main branch.
In a Unix terminal, the question "what is the highest tag currently pointing at the current commit" can be answered by the following command:
git tag --points-at "${sha}" | sort -n | tail -1
Something similar should be possible to do with libgit2sharp, I presume.
What is expected?
GitVersion should run on a checked out tag without problems and calculate a version as if it was a tagged commit on main
.
Steps to Reproduce
I assumed a GitHub Actions workflow like this would be able to reproduce the issue consistently, but it unfortunately doesn't:
name: Deploy
on:
workflow_dispatch:
jobs:
gitversion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '6.x'
- uses: gittools/actions/gitversion/[email protected]
I've tried to reproduce the problem in this workflow run, but for some reason, it doesn't fail. The main difference is the following log line:
INFO [24-09-18 9:18:19:08] No local branch pointing at the commit 'bd0483d972605906d5cc1d748c84c90a485d29ad'. Fake branch needs to be created.
GitVersion then goes on to attempt git fetch
of the remote, which fails because GitVersion isn't authenticated. As GitVersion already should know that tag 1.4.1
points to the commit bd0483d972605906d5cc1d748c84c90a485d29ad
(as can be seen by the log), it should just use 1.4.1
as the version number and not attempt any further normalization, Git fetch, or similar.
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
No response