Gitversion: [Windows][Appveyor] InvalidSpecificationException: the given reference name '[branch]' is not valid

Created on 25 Feb 2020  路  16Comments  路  Source: GitTools/GitVersion

Version: 5.1.3

Really not sure what's going on here, but after trying a few different things I'm stumped:

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 
bug

Most helpful comment

I think the issue is that the branch contains refs in the name (all 3 attempts had that in the name)

Confirmed this is the issue (a new PR submitted without containing refs passes). 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.

All 16 comments

I think the issue is that the branch contains refs in the name (all 3 attempts had that in the name)

@arturcic ugh, you might be right. Any idea why libgit2sharp would complain about that?

I think that's a question for Libgit2Sharp repo

I think the issue is that the branch contains refs in the name (all 3 attempts had that in the name)

Confirmed this is the issue (a new PR submitted without containing refs passes). 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.

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.

@asbjornu I'd like to figure out why it's only failing on Windows too (as someone who has contributed to libgit2sharp before, I'd like to know why this is failing because it seems a bit absurd).

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.

@shiftkey, have you had any time to look into this? No rush, just thought I'd ask now that @stalebot reminded me.

@asbjornu nah, haven't even opened Windows since then

same behavior on Jenkins :

* 64fa46db 3 weeks ago 

INFO [06/01/20 15:42:24:11] Applicable build agent found: 'Jenkins'.INFO [06/01/20 15:42:24:12] Working directory: D:\workspace\NoTicket.FixF---19159f93INFO [06/01/20 15:42:24:12] IsDynamicGitRepository: FalseINFO [06/01/20 15:42:24:13] Returning Project Root from DotGitDirectory: D:\workspace\NoTicket.FixF---19159f93\.git\ - D:\workspace\NoTicket.FixF---19159f93\INFO [06/01/20 15:42:24:13] Running on Windows.INFO [06/01/20 15:42:24:13] Applicable build agent found: 'Jenkins'.INFO [06/01/20 15:42:24:13] Branch from build environment: NoTicket.FixFixUserPrefsForSiteMapINFO [06/01/20 15:42:24:14] Begin: Normalizing git directory for branch 'NoTicket.FixFixUserPrefsForSiteMap'  INFO [06/01/20 15:42:24:15] One remote found (origin -> '[email protected]:LuccaSA/Cleemy.Expenses.git').  INFO [06/01/20 15:42:24:15] Skipping fetching, if GitVersion does not calculate your version as expected you might need to allow fetching or use dynamic repositories  INFO [06/01/20 15:42:24:15] Creating local branch NoTicket.FixFixUserPrefsForSiteMap pointing at a8beb1b0348320ed75e88d072aea87bec4bf7010  INFO [06/01/20 15:42:24:16] End: Normalizing git directory for branch 'NoTicket.FixFixUserPrefsForSiteMap' (Took: 20.92ms)  ERROR [06/01/20 15:42:24:17] An unexpected error occurred:
LibGit2Sharp.InvalidSpecificationException: the given reference name 'NoTicket.FixFixUserPrefsForSiteMap' is not valid
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.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 [06/01/20 15:42:24:17]   INFO [06/01/20 15:42:24:17] Attempting to show the current git graph (please include in issue):   INFO [06/01/20 15:42:24:17] Showing max of 100 commits  INFO [06/01/20 15:42:24:21] * a8beb1b0 44 seconds ago  (HEAD -> NoTicket.FixFixUserPrefsForSiteMap, origin/NoTicket.FixFixUserPrefsForSiteMap)
| * e01172b9 28 minutes ago  (origin/v2.5.28_FixUserPrefsForSiteMap)
|/  
* 246a8f59 2 hours ago  (tag: v2.5.28, origin/master)

Changing branch name from NoTicket.FixFixUserPrefsForSiteMap to FixFixUserSettingsForSiteMap is a working waorkaround

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.

No the "refs" sub string is causing problem

Ok, then I misunderstood this:

Changing branch name from NoTicket.FixFixUserPrefsForSiteMap to FixFixUserSettingsForSiteMap is a working waorkaround

There is "refs" in "Prefs" 馃槃

Yikes! Right you are! I didn't even notice the removal of Prefs. That's profoundly bizarre.

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.

Was this page helpful?
0 / 5 - 0 ratings