Repository navigation
Closed
Labels
Milestone
Description
Version: 5.1.3
Really not sure what's going on here, but after trying a few different things I'm stumped:
- three failing PRs with the same content today: Allow fully qualified or short references to be used to generate "reference" Uri octokit/octokit.net#2104 Allow fully qualified or short references to be used to generate "reference" Uri octokit/octokit.net#2107 and Allow fully qualified or short references to be used to generate "reference" Uri octokit/octokit.net#2108
- GitHub Actions on macOS and Linux not reporting problem
- pull request submitted from branch or fork - same result
- different branch names triggering it for seemingly the same content
- meanwhile other pull requests today haven't had issues when going through the exact same process
Calculating semantic version...
INFO [02/24/20 23:50:44:59] Working directory: C:\projects\octokit-net
INFO [02/24/20 23:50:44:59] IsDynamicGitRepository: False
INFO [02/24/20 23:50:44:61] Returning Project Root from DotGitDirectory: C:\projects\octokit-net\.git\ - C:\projects\octokit-net\
INFO [02/24/20 23:50:44:62] Running on Windows.
INFO [02/24/20 23:50:44:62] Applicable build agent found: 'AppVeyor'.
INFO [02/24/20 23:50:44:62] Branch from build environment: fully-qualified-refs-fix
INFO [02/24/20 23:50:44:62] Begin: Normalizing git directory for branch 'fully-qualified-refs-fix'
INFO [02/24/20 23:50:44:65] One remote found (origin -> 'https://github.com/octokit/octokit.net.git').
INFO [02/24/20 23:50:44:65] Fetching from remote 'origin' using the following refspecs: +refs/heads/*:refs/remotes/origin/*.
INFO [02/24/20 23:50:44:98] Creating local branch fully-qualified-refs-fix pointing at 3204b734e94cf4f25891a3d0d29d607af5912076
INFO [02/24/20 23:50:44:99] End: Normalizing git directory for branch 'fully-qualified-refs-fix' (Took: 365.39ms)
dotnet : ERROR [02/24/20 23:50:45:01] An unexpected error occurred:
At line:1 char:1
+ dotnet run -- --configuration="Release" --linkSources="True" --dryrun ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( ERROR [02/24/...error occurred::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
LibGit2Sharp.InvalidSpecificationException: the given reference name 'fully-qualified-refs-fix' is not valid
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.En
sure.ZeroResult(Int32 result)
at LibGit2Sharp.Core.Proxy.git_reference_create(RepositoryHandle repo, String name, ObjectId targetId, Boolean allowOverwrite, String logMessage)
at LibGit2Sharp.ReferenceCollection.Add(String name, ObjectId targetId, String logMessage, Boolean allowOverwrite)
at LibGit2Sharp.ReferenceCollection.Add(String name, ObjectId targetId)
at GitVersion.Helpers.GitRepositoryHelper.EnsureLocalBranchExistsForCurrentBranch(ILog log, Repository repo, Remote remote, String currentBranch) in D:\a\1\s\src\GitVersionCore\Helpers\GitRepositoryHelper.cs:line 171
at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository)
in D:\a\1\s\src\GitVersionCore\Helpers\GitRepositoryHelper.cs:line 41
at GitVersion.GitPreparer.NormalizeGitDirectory(AuthenticationInfo auth, String targetBranch, String gitDirectory, Boolean isDynamicRepository) in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 190
at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes) in D:\a\1\s\src\GitVersionCore\GitPreparer.cs:line 65
at GitVersion.GitVersionCalculator.CalculateVersionVariables() in D:\a\1\s\src\GitVersionCore\GitVersionCalculator.cs:line 54
at GitVersion.ExecCommand.Execute() in D:\a\1\s\src\GitVersionExe\ExecCommand.cs:line 40
at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments) in D:\a\1\s\src\GitVersionExe\GitVersionExecutor.cs:line 117
INFO [02/24/20 23:50:45:01]
INFO [02/24/20 23:50:45:01] Attempting to show the current git graph (please include in issue):
INFO [02/24/20 23:50:45:01] Showing max of 100 commits
INFO [02/24/20 23:50:45:18] * 3204b734 3 minutes ago (HEAD)
|\
| * 9238e1dc 65 minutes ago
|/
* eee57895 2 hours ago (origin/master, origin/HEAD, master)
* 5223d1af 2 hours ago
* 6fdd800f 6 hours ago (tag: v0.41.0)
* fe6639f2 9 hours ago
| * 2bb02f26 23 hours ago (origin/brave-new-codegen-world)
| * 746921f4 29 hours ago
| * 314ef922 30 hours ago
| * db522495 2 days ago
| * 3dee4789 2 days ago
| * 868c6689 2 days ago
| * fc88eda0 2 days ago
| * 15becc92 2 days ago
| * 7c08319d 2 days ago
| * 6f9f34b2 2 days ago
| * 7f0d9316 2 days ago
| * 45a37383 3 days ago
| * 93f4697d 3 days ago
| * 0325e61c 3 days ago
| * 1693ffbf 3 days ago
| * 413b118e 3 days ago
| * 673e7343 3 days ago
| * cd1088af 3 days ago
| * 5c51bde4 3 days ago
| * 0b5af237 3 days ago
| * 85aba44e 3 days ago
| * 33ddddcf 3 days ago
| * 96098369 4 days ago
| * 45672ad6 4 days ago
| * 43530694 4 days ago
| * ad309879 4 days ago
| * dfdcc6ef 4 days ago
| * 98495de3 4 days ago
| * ddb35c15 4 days ago
| * 40df2e92 4 days ago
| * 9beb2e6d 4 days ago
| * 4641f261 4 days ago
| * 7384a561 4 days ago
| * cb233046 4 days ago
| * 498c2865 4 days ago
| * 189aa1bf 5 days ago
| * 6bb8b0e4 5 days ago
|/
* 0074e76a 6 days ago
* 804aa483 13 days ago
* 9f6de380 2 weeks ago
* 2b2626be 2 weeks ago
* 5de37916 2 weeks ago (tag: v0.40.0)
* 736c3bd3 2 weeks ago
| * 3edbcaac 2 weeks ago (origin/bringing-windows-back)
|/
* 8dac9688 2 weeks ago (tag: v0.39.0)
* 8cf4d584 2 weeks ago
* 911dd4a9 2 weeks ago
* 9b136b1f 2 weeks ago
* 26d770b2 2 weeks ago (tag: v0.38.0)
* d4b86011 2 weeks ago
* 56895ea6 3 weeks ago
* 45621c0c 3 weeks ago
* 2d0124f8 3 weeks ago
* 321c9ba5 4 weeks ago (tag: v0.37.0)
* 52902027 4 weeks ago
* 03aa9089 4 weeks ago
* 43ae40fa 4 weeks ago
* e065c861 4 weeks ago
* 44dc2a9e 4 weeks ago
* bbae5190 4 weeks ago
* 2431bb48 4 weeks ago
* 39fb9f6a 4 weeks ago
* d8e6008b 4 weeks ago
* 8605b8cf 4 weeks ago
* 7669dcbc 5 weeks ago
* 28892df0 5 weeks ago
* 00f60510 5 weeks ago
* 6719e870 5 weeks ago
* 95d4951f 5 weeks ago
* e9409e0c 5 weeks ago
* a05d49e8 3 months ago
* fd6bca91 3 months ago
* f61654a7 4 months ago
* 5eb9f06b 4 months ago
* 8b263cdc 4 months ago
* 90812951 4 months ago
* 311e89a5 5 months ago (tag: v0.36.0)
* 3e7c70cf 5 months ago
* ce5ea644 5 months ago (tag: v0.35.0)
* aeb8d19f 5 months ago
| * ac8ac6fa 5 months ago (origin/management-console-authorized-ssh-keys)
| * 0c3fbeb5 5 months ago
| * 92e3ca79 5 months ago
| * 6719e5af 5 months ago
| * 8efec609 5 months ago
| * fb85a7a4 5 months ago
| * 1e9079b5 5 months ago
| * 4ef04e0a 5 months ago
| * 1c6f70ad 5 months ago
| * e08ac388 5 months ago
| * 266b9a62 5 months ago
| * 1415dc3b 5 months ago
| * e0d5a74e 5 months ago
| * 835e1573 5 months ago
Activity
arturcic commentedon Feb 25, 2020
I think the issue is that the branch contains
refsin the name (all 3 attempts had that in the name)shiftkey commentedon Feb 25, 2020
@arturcic ugh, you might be right. Any idea why
libgit2sharpwould complain about that?arturcic commentedon Feb 25, 2020
I think that's a question for Libgit2Sharp repo
shiftkey commentedon Feb 25, 2020
Confirmed this is the issue (a new PR submitted without containing
refspasses). Going to leave this open for a bit to remind myself to try and reproduce it in isolation and see if I can put something on the libgit2sharp tracker.asbjornu commentedon Feb 25, 2020
If changing the name of the branch helps, I'd say that's a bug in GitVersion. Best case, we should handle that gracefully, worst case we should yield an understandable error message indicating that the name of the branch could be the perpetrator.
shiftkey commentedon Feb 25, 2020
@asbjornu I'd like to figure out why it's only failing on Windows too (as someone who has contributed to
libgit2sharpbefore, I'd like to know why this is failing because it seems a bit absurd).stale commentedon May 25, 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.
asbjornu commentedon May 25, 2020
@shiftkey, have you had any time to look into this? No rush, just thought I'd ask now that @stalebot reminded me.
shiftkey commentedon May 25, 2020
@asbjornu nah, haven't even opened Windows since then
rducom commentedon Jun 1, 2020
same behavior on Jenkins :
Changing branch name from
NoTicket.FixFixUserPrefsForSiteMaptoFixFixUserSettingsForSiteMapis a working waorkaroundasbjornu commentedon Jun 2, 2020
So the
NoTicket.prefix is causing problems, @rducom? Perhaps the.in there? Bizarre, whategver it is. The best way to fix this would be to provide a failing test in the LibGit2Sharp repository, I think.rducom commentedon Jun 2, 2020
No the "refs" sub string is causing problem
asbjornu commentedon Jun 2, 2020
Ok, then I misunderstood this:
7 remaining items
asbjornu commentedon Jan 27, 2021
Given the stack trace, I would say this is a bug in LibGit2Sharp or perhaps even in libgit2. I at least have no idea how we can fix this in GitVersion. Pull requests and ideas are of course welcome.
hotchkj commentedon Jan 27, 2021
@asbjornu Understood & I'd be quite comfortable with this blocked by a corresponding issue on LibGit2Sharp - I am just not sure if I have the background information necessary to raise it.
asbjornu commentedon Jan 27, 2021
I wish I could help, but I'm not experienced in the LibGit2Sharp or libgit2 source code myself.
hotchkj commentedon Jan 27, 2021
Looking at the spec for
git_reference_create, the fundamental problem seems to be a parsing or data error somewhere prior. The name passed togit_reference_createisn't faulty because it containsrefs. It's faulty period - it should be a canonical name in the form e.g.refs\heads\fully-qualified-refs-fix.This appears to be a bug at
GitVersion/src/GitVersionCore/Core/GitPreparer.cs
Line 323 in 72ee9ea
Prior code & logging indicates that
currentBranchpassed to this functionEnsureLocalBranchExistsForCurrentBranchis e.g. from logs earlier inGitPreparerwhich is not canonical.
Running this code down to the
ReferenceCollection.Addyields a call into LibGit2Sharp ofwhich will inevitably crash. Remove the
refspart and it will instead call asAside: This is likely why
Addis being called, because as far as I can tell these branches do already exist, rather than should be created, but the comparison inif (repo.Branches.All(b => !b.Name.Equals(referenceName)))likely fails for the same reason.asbjornu commentedon Jan 28, 2021
Thanks for the digging, @hotchkj! Perhaps more logging in that area of the GitVersion code may help figure out where the bug may be?
hotchkj commentedon Jan 28, 2021
Possibly more logs may help. I think the information this report is currently lacking is why this works in the general case but not on Windows. What I am curious about, and I suspect only the author of the relevant GitVersion code can answer, is what the following segment is expected to returned:
GitVersion/src/GitVersionCore/Core/GitPreparer.cs
Lines 79 to 93 in 72ee9ea
As far as I can tell from following the code through, the fault is either in the aforementioned GitVersionCore's
EnsureLocalBranchExistsForCurrentBranchbecause it assumes the presence of the stringrefsis enough to validate the presence of a canonical name, or the fault lies above in whatever this code does, because it should have reported a canonical name and didn't (perhaps it assumes the build agent reports in a given fashion and that has changed?). There are no comments to determine intent from this outside observer though.All that said, it seems likely that the data is coming from a tool outside GitVersion's control, so it may just be better to harden the checking in
EnsureLocalBranchExistsForCurrentBranch.asbjornu commentedon Jan 28, 2021
That sounds like a very plausible cause, indeed!
Agreed! The search for
refsshould at least include/, I'd say. Ideas for how this can be made even more robust and pull requests implementing them are welcome and appreciated. 🙏🏼asbjornu commentedon Nov 11, 2021
If an upgrade of LibGit2Sharp helps with this problem, #2916 should prove useful.
HHobeck commentedon Apr 4, 2023
This has been properly solved with #3103. If this error still persists in version 6.x please let me know and re-open this issue. Thank you very much.
arturcic commentedon Apr 6, 2023
🎉 This issue has been resolved in version 6.0.0-beta.2 🎉
The release is available on:
Your GitReleaseManager bot 📦🚀
hugofe commentedon May 29, 2023
Hey Guys!

I think the problem was not solved yet. I am testing the gitversion in our pipelines on Azure Devops and I am getting the following error. As you can see I am in the version 6.0.0-beta.2
2023-05-29T10:25:13.0536713Z ERROR [05/29/23 10:25:12:96] An unexpected error occurred:
2023-05-29T10:25:13.0536845Z * | | | | | | 9652a8a4 5 days ago
2023-05-29T10:25:13.0537452Z LibGit2Sharp.InvalidSpecificationException: the given reference name 'refs/heads/origin/refs/heads/development ' is not valid
2023-05-29T10:25:13.0537774Z at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154
2023-05-29T10:25:13.0538023Z at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 172
2023-05-29T10:25:13.0538339Z at LibGit2Sharp.Core.Proxy.git_reference_lookup(RepositoryHandle repo, String name, Boolean shouldThrowIfNotFound) in //LibGit2Sharp/Core/Proxy.cs:line 1953
2023-05-29T10:25:13.0538565Z
2023-05-29T10:25:13.0538887Z INFO [05/29/23 10:25:12:83] Applicable build agent found: 'AzurePipelines'.
2023-05-29T10:25:13.0539148Z INFO [05/29/23 10:25:12:89] Working directory: /home/vsts/work/r1/a/ETF
2023-05-29T10:25:13.0539407Z INFO [05/29/23 10:25:12:90] Project root is: /home/vsts/work/r1/a/ETF/
2023-05-29T10:25:13.0539655Z INFO [05/29/23 10:25:12:90] DotGit directory is: /home/vsts/work/r1/a/ETF/.git
2023-05-29T10:25:13.0539983Z at LibGit2Sharp.ReferenceCollection.RetrieveReferencePtr(String referenceName, Boolean shouldThrowIfNotFound) in //LibGit2Sharp/ReferenceCollection.cs:line 676
2023-05-29T10:25:13.0540247Z INFO [05/29/23 10:25:12:90] Branch from build environment: refs/heads/development
2023-05-29T10:25:13.0540525Z at LibGit2Sharp.ReferenceCollection.Resolve[T](String name) in //LibGit2Sharp/ReferenceCollection.cs:line 441
2023-05-29T10:25:13.0540947Z INFO [05/29/23 10:25:12:90] Begin: Normalizing git directory for branch 'refs/heads/development '
2023-05-29T10:25:13.0541382Z INFO [05/29/23 10:25:12:93] One remote found (origin -> 'https://UNFCCC-ICT@dev.azure.com/UNFCCC-ICT/ETF/_git/ETF').
2023-05-29T10:25:13.0543278Z INFO [05/29/23 10:25:12:93] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories
2023-05-29T10:25:13.0543687Z INFO [05/29/23 10:25:12:94] End: Normalizing git directory for branch 'refs/heads/development ' (Took: 39.96ms)
2023-05-29T10:25:13.0543878Z ERROR [05/29/23 10:25:12:96] An unexpected error occurred:
2023-05-29T10:25:13.0544199Z LibGit2Sharp.InvalidSpecificationException: the given reference name 'refs/heads/origin/refs/heads/development ' is not valid
2023-05-29T10:25:13.0544438Z at LibGit2Sharp.Core.Ensure.HandleError(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 154
2023-05-29T10:25:13.0544647Z at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result) in //LibGit2Sharp/Core/Ensure.cs:line 172
2023-05-29T10:25:13.0544908Z at LibGit2Sharp.Core.Proxy.git_reference_lookup(RepositoryHandle repo, String name, Boolean shouldThrowIfNotFound) in //LibGit2Sharp/Core/Proxy.cs:line 1953
2023-05-29T10:25:13.0545206Z at LibGit2Sharp.ReferenceCollection.RetrieveReferencePtr(String referenceName, Boolean shouldThrowIfNotFound) in //LibGit2Sharp/ReferenceCollection.cs:line 676
2023-05-29T10:25:13.0545470Z at LibGit2Sharp.ReferenceCollection.Resolve[T](String name) in //LibGit2Sharp/ReferenceCollection.cs:line 441
2023-05-29T10:25:13.0545729Z at LibGit2Sharp.BranchCollection.BuildFromReferenceName(String canonicalName) in //LibGit2Sharp/BranchCollection.cs:line 82
2023-05-29T10:25:13.0546060Z at LibGit2Sharp.BranchCollection.get_Item(String name) in /_/LibGit2Sharp/BranchCollection.cs:line 49
2023-05-29T10:25:13.0546335Z at GitVersion.BranchCollection.get_Item(String name) in D:\a\GitVersion\GitVersion\src\GitVersion.LibGit2Sharp\Git\BranchCollection.cs:line 23
2023-05-29T10:25:13.0546657Z at GitVersion.GitPreparer.EnsureLocalBranchExistsForCurrentBranch(IRemote remote, String currentBranch) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 377
2023-05-29T10:25:13.0547033Z at GitVersion.GitPreparer.NormalizeGitDirectory(Boolean noFetch, String currentBranchName, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 163
2023-05-29T10:25:13.0547385Z at GitVersion.GitPreparer.NormalizeGitDirectory(String targetBranch, Boolean isDynamicRepository) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 134
2023-05-29T10:25:13.0547726Z at GitVersion.GitPreparer.PrepareInternal(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 69
2023-05-29T10:25:13.0548010Z at GitVersion.GitPreparer.Prepare() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitPreparer.cs:line 48
2023-05-29T10:25:13.0548294Z at GitVersion.GitVersionCalculateTool.CalculateVersionVariables() in D:\a\GitVersion\GitVersion\src\GitVersion.Core\Core\GitVersionCalculateTool.cs:line 43
2023-05-29T10:25:13.0548635Z at GitVersion.GitVersionExecutor.RunGitVersionTool(GitVersionOptions gitVersionOptions) in D:\a\GitVersion\GitVersion\src\GitVersion.App\GitVersionExecutor.cs:line 65
2023-05-29T10:25:13.0548898Z INFO [05/29/23 10:25:12:96] Attempting to show the current git graph (please include in issue):
2023-05-29T10:25:13.0549089Z INFO [05/29/23 10:25:12:96] Showing max of 100 commits
2023-05-29T10:25:13.0549375Z INFO [05/29/23 10:25:13:03] * f7d65f31 6 minutes ago (origin/feature/ETF-3569-aci-with-tf)