Skip to content

Commit 32ef01e

Browse files
committed
fix: add helpful error message for git repository issues
1 parent f544626 commit 32ef01e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/header/check.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"github.com/bmatcuk/doublestar/v2"
3535
"github.com/go-git/go-billy/v5/osfs"
3636
"github.com/go-git/go-git/v5"
37+
"github.com/go-git/go-git/v5/plumbing"
3738
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
3839
"github.com/go-git/go-git/v5/plumbing/object"
3940
"golang.org/x/sync/errgroup"
@@ -122,6 +123,9 @@ func listFiles(config *ConfigHeader) ([]string, error) {
122123
candidates = append(candidates, file.Name)
123124
return nil
124125
}); err != nil {
126+
if errors.Is(err, plumbing.ErrObjectNotFound) {
127+
return nil, errors.New("failed to read git repository. Run 'git fsck' to diagnose. If dangling objects are found, run: git prune && git gc --prune=now --aggressive")
128+
}
125129
return nil, err
126130
}
127131
}

0 commit comments

Comments
 (0)