go-git / go-git

A highly extensible Git implementation in pure Go.
https://pkg.go.dev/github.com/go-git/go-git/v5
Apache License 2.0
5.87k stars 734 forks source link

PlainCloneContext failing - but only in GitHub Actions #726

Open bobg opened 1 year ago

bobg commented 1 year ago

[It's not a fetch-depth problem.]

Hello! I have some code that calls PlainCloneContext with a local .git dir as the URL. It works fine when I run it on my Macbook, and when I run it on my Linux desktop. And it worked fine in GitHub Actions in a recent version of my project. But it fails on my current feature branch, even though no relevant code has changed.

The project is modver, a package and command-line tool for helping your Go project to obey semantic versioning rules. In the function CompareGitWith, an older and a newer version of a Git repo are compared to each other; the cloning happens in the helper function gitSetup here.

Here is the line in the TestGit unit test that calls CompareGitWith (via an intermediate call to CompareGit). Here is the GitHub Actions workflow that runs that test. And here you can see it working in a commit on the master branch from just a few weeks ago.

But it's failing in this draft PR with an "object not found" error. Example.

Take a look at the last several commits in that PR branch to see the various permutations of things I tried to fix this, to no avail. I am pretty baffled. Any help?

AriehSchneier commented 1 year ago

Is this issue #148?

If it is a workaround is to add this line after your PlainOpen: _, _ = repo.ResolveRevision(plumbing.Revision(plumbing.ZeroHash.String()))

I have a PR open to fix it.

bobg commented 1 year ago

Thank you @AriehSchneier but apparently not. I tried your workaround and got the same result.

bobg commented 1 year ago

On the other hand, this workaround (using an https repo URL instead of a local directory) did work.