Any idea why I would get this error and is there anyway to ignore the error? The error is LibGit2Sharp.NotFoundException: Object not found - no match for id
@ryudice: Does this happen in a public repository? If not, can you reproduce it in a public repository we can inspect? Which version of GitVersion are you using? Are you using the MSBuild Task or .exe?
Usually, this exception occurs if you have a shallow repository or have only cloned a branch and not the whole repository. Does this happen locally or on a build server?
@asbjornu It seems it was a shallow clone causing the issue, after doing the full clone seems to be ok, maybe a more descriptive error would be good?
Thanks for you help.
@ryudice: I completely agree that a more descriptive error would be good. If you can figure out where we can catch the LibGit2Sharp.NotFoundException in GitVersion and wrap it in a custom exception, it would be a simple thing to fix. Want to take on that task in a pull request or just write down your findings in here?
Hi,
Not sure it's the same cause, but I got the same exception.
Here is the full stacktrace:
ERROR [10/21/16 15:44:39:77] An unexpected error occurred:
LibGit2Sharp.NotFoundException: Object not found - no match for id (5a8f976b3c528351cef3d7f632721bfdc785e9c)
at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
at LibGit2Sharp.Core.Proxy.git_revwalk_next(RevWalkerHandle walker)
at LibGit2Sharp.CommitLog.CommitEnumerator.MoveNext()
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at GitVersion.VersionCalculation.FallbackBaseVersionStrategy.<GetVersions>d__0.MoveNext()
at System.Linq.Enumerable.<SelectManyIterator>d__16`2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at GitVersion.VersionCalculation.BaseVersionCalculator.GetBaseVersion(GitVersionContext context)
at GitVersion.VersionCalculation.NextVersionCalculator.FindVersion(GitVersionContext context)
at GitVersion.GitVersionFinder.FindVersion(GitVersionContext context)
at GitVersion.ExecuteCore.<>c__DisplayClass6_0.<ExecuteInternal>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)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()
I git this error while testing the new Shallow clone in VSTS:
https://www.visualstudio.com/en-us/docs/build/define/repository#git
And then at the end of the script, I got:
##[error]System.Exception: Unexpected exit code 1 returned from tool GitVersion.exe
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]PowerShell script completed with 1 errors.
I think in case of shallow clone (with an option?) you should ignore this errors
This seems to be an instance of the same issue: https://travis-ci.org/NUnitSoftware/nunit-gui/jobs/271064871#L2026
I'm in the process of adding GitVersion to the NUnit GUI build. Haven't been able to get it to work on Travis under Linux although the problem doesn't occur on Windows with AppVeyor or locally. Haven't had a chance to try it locally on Linux yet. The failure occurs in the initial call to retrieve a GitVersion instance in my Cake script.
@CharliePoole: Is Travis doing a shallow clone? If so, does git fetch --unshallow before running GitVersion fix the problem?
@asbjornu Thanks... I found that option and implemented it... works great!
It would be better, I think, if GitVersion did something better with that exception. LibGit2Sharp has to throw here, since it doesn't know the purpose of the call. But GitVersion knows what it's doing and could either try to deal with the shallow clone or at least give a better message where that turns out to be the case.
@CharliePoole: I completely agree, which is why I suggested that solution in https://github.com/GitTools/GitVersion/issues/1043#issuecomment-253143292. I've submitted #1287 which should improve the thrown exception. 馃槂
I'm seeing this is my repo here: https://travis-ci.com/solidclouddev/plivo-dotnet/jobs/162238939
Not sure how to fix this?
@solidclouddev: It seems like you're using Nerdbank.GitVersioning and not GitTools.GitVersion, so I'm not sure this is the right repository to ask?
Most helpful comment
@asbjornu It seems it was a shallow clone causing the issue, after doing the full clone seems to be ok, maybe a more descriptive error would be good?
Thanks for you help.