|
|
@ -268,13 +268,21 @@ const ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
type RepoFile struct { |
|
|
|
type RepoFile struct { |
|
|
|
Type int |
|
|
|
Type int |
|
|
|
Name string |
|
|
|
Name string |
|
|
|
|
|
|
|
Message string |
|
|
|
Created time.Time |
|
|
|
Created time.Time |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, error) { |
|
|
|
func (f *RepoFile) IsFile() bool { |
|
|
|
|
|
|
|
return f.Type == git.FilemodeBlob || f.Type == git.FilemodeBlobExecutable |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (f *RepoFile) IsDir() bool { |
|
|
|
|
|
|
|
return f.Type == git.FilemodeTree |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func GetReposFiles(userName, reposName, treeName, rpath string) ([]*RepoFile, error) { |
|
|
|
f := RepoPath(userName, reposName) |
|
|
|
f := RepoPath(userName, reposName) |
|
|
|
repo, err := git.OpenRepository(f) |
|
|
|
repo, err := git.OpenRepository(f) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -286,7 +294,7 @@ func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, err |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
|
} |
|
|
|
} |
|
|
|
lastCommit := obj.(*git.Commit) |
|
|
|
lastCommit := obj.(*git.Commit) |
|
|
|
var repofiles []RepoFile |
|
|
|
var repofiles []*RepoFile |
|
|
|
tree, err := lastCommit.Tree() |
|
|
|
tree, err := lastCommit.Tree() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return nil, err |
|
|
@ -294,10 +302,12 @@ func GetReposFiles(userName, reposName, treeName, rpath string) ([]RepoFile, err |
|
|
|
var i uint64 = 0 |
|
|
|
var i uint64 = 0 |
|
|
|
for ; i < tree.EntryCount(); i++ { |
|
|
|
for ; i < tree.EntryCount(); i++ { |
|
|
|
entry := tree.EntryByIndex(i) |
|
|
|
entry := tree.EntryByIndex(i) |
|
|
|
repofiles = append(repofiles, RepoFile{ |
|
|
|
|
|
|
|
|
|
|
|
repofiles = append(repofiles, &RepoFile{ |
|
|
|
entry.Filemode, |
|
|
|
entry.Filemode, |
|
|
|
entry.Name, |
|
|
|
entry.Name, |
|
|
|
time.Now(), |
|
|
|
lastCommit.Message(), |
|
|
|
|
|
|
|
lastCommit.Committer().When, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|