File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
internal/attestation/crafter Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,9 @@ type CommitRemote struct {
253253 Name , URL string
254254}
255255
256+ // This error is not exposed by go-git
257+ var errBranchInvalidMerge = errors .New ("branch config: invalid merge" )
258+
256259// Returns the current directory git commit hash if possible
257260// If we are not in a git repo it will return an empty string
258261func gracefulGitRepoHead (path string ) (* HeadCommit , error ) {
@@ -293,6 +296,14 @@ func gracefulGitRepoHead(path string) (*HeadCommit, error) {
293296
294297 remotes , err := repo .Remotes ()
295298 if err != nil {
299+ // go-git does an additional validation that the branch is pushed upstream
300+ // we do not care about that use-case, so we ignore the error
301+ // we compare by error string because go-git does not expose the error type
302+ // and errors.Is require the same instance of the error
303+ if err .Error () == errBranchInvalidMerge .Error () {
304+ return c , nil
305+ }
306+
296307 return nil , fmt .Errorf ("getting remotes: %w" , err )
297308 }
298309
You can’t perform that action at this time.
0 commit comments