1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 12:54:53 -05:00

bug fixed

This commit is contained in:
Lunny Xiao 2014-03-17 20:16:58 +08:00
parent f2b0dc18b5
commit be8baea7ad

View file

@ -37,28 +37,6 @@ type RepoFile struct {
LastCommit string LastCommit string
} }
func findTree(repo *git.Repository, tree *git.Tree, rpath string) *git.Tree {
if rpath == "" {
return tree
}
paths := strings.Split(rpath, "/")
var g = tree
for _, p := range paths {
s := g.EntryByName(p)
if s == nil {
return nil
}
g, err := repo.LookupTree(s.Id)
if err != nil {
return nil
}
if g == nil {
return nil
}
}
return g
}
func (file *RepoFile) LookupBlob() (*git.Blob, error) { func (file *RepoFile) LookupBlob() (*git.Blob, error) {
if file.Repo == nil { if file.Repo == nil {
return nil, ErrRepoFileNotLoaded return nil, ErrRepoFileNotLoaded
@ -116,7 +94,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
if cm.ParentCount() == 0 { if cm.ParentCount() == 0 {
break break
} else if cm.ParentCount() == 1 { } else if cm.ParentCount() == 1 {
pt := findTree(repo, cm.Parent(0).Tree, dirname) pt, _ := repo.SubTree(cm.Parent(0).Tree, dirname)
if pt == nil { if pt == nil {
break break
} }
@ -131,7 +109,7 @@ func GetReposFiles(userName, reposName, branchName, rpath string) ([]*RepoFile,
var sameIdcnt = 0 var sameIdcnt = 0
for i := 0; i < cm.ParentCount(); i++ { for i := 0; i < cm.ParentCount(); i++ {
p := cm.Parent(i) p := cm.Parent(i)
pt := findTree(repo, p.Tree, dirname) pt, _ := repo.SubTree(p.Tree, dirname)
var pEntry *git.TreeEntry var pEntry *git.TreeEntry
if pt != nil { if pt != nil {
pEntry = pt.EntryByName(entry.Name) pEntry = pt.EntryByName(entry.Name)