git: fetch files only using ref

This commit is contained in:
Anirudh Oppiliappan 2022-12-11 12:29:33 +05:30
parent 856f66808b
commit d62fb1442b
No known key found for this signature in database
GPG Key ID: 8A93F96F78C5D4C4
1 changed files with 2 additions and 11 deletions

View File

@ -31,17 +31,8 @@ type NiceTree struct {
IsFile bool IsFile bool
} }
func FilesAtHead(r *git.Repository, path string) ([]NiceTree, error) { func FilesAtRef(r *git.Repository, hash plumbing.Hash, path string) ([]NiceTree, error) {
head, err := r.Head() c, err := r.CommitObject(hash)
if err != nil {
return nil, fmt.Errorf("getting head: %w", err)
}
return FilesAtRef(r, head, path)
}
func FilesAtRef(r *git.Repository, ref *plumbing.Reference, path string) ([]NiceTree, error) {
c, err := r.CommitObject(ref.Hash())
if err != nil { if err != nil {
return nil, fmt.Errorf("commit object: %w", err) return nil, fmt.Errorf("commit object: %w", err)
} }