1
0
Fork 0
forked from forgejo/forgejo

Fix #6813: Allow git.GetTree to take both commit and tree names (#6816)

* Allow git.GetTree to take both commit and tree names, return full paths on entries listed through Tree.ListEntriesRecursive

Signed-off-by: Filip Navara <filip.navara@gmail.com>

* Fix the SHA returned on Git Tree APIs called with commit hash or symbolic name

Signed-off-by: Filip Navara <filip.navara@gmail.com>
This commit is contained in:
Filip Navara 2019-05-03 02:33:11 +02:00 committed by techknowlogick
parent a27d5d2b23
commit dbb0c9658c
4 changed files with 18 additions and 12 deletions

View file

@ -15,9 +15,9 @@ import (
// Tree represents a flat directory listing.
type Tree struct {
ID SHA1
CommitID SHA1
repo *Repository
ID SHA1
ResolvedID SHA1
repo *Repository
gogitTree *object.Tree
@ -106,7 +106,7 @@ func (t *Tree) ListEntriesRecursive() (Entries, error) {
seen := map[plumbing.Hash]bool{}
walker := object.NewTreeWalker(t.gogitTree, true, seen)
for {
_, entry, err := walker.Next()
fullName, entry, err := walker.Next()
if err == io.EOF {
break
}
@ -121,6 +121,7 @@ func (t *Tree) ListEntriesRecursive() (Entries, error) {
ID: entry.Hash,
gogitTreeEntry: &entry,
ptree: t,
fullName: fullName,
}
entries = append(entries, convertedEntry)
}