Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 68afabe

Browse files
author
Lei Da
committed
return path and committer date in GetDir api
1 parent bc85588 commit 68afabe

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

modules/structs/repo_tree.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@
33

44
package structs
55

6+
import "time"
7+
68
// GitEntry represents a git tree
79
type GitEntry struct {
8-
Path string `json:"path"`
9-
Mode string `json:"mode"`
10-
Type string `json:"type"`
11-
Size int64 `json:"size"`
12-
SHA string `json:"sha"`
13-
URL string `json:"url"`
14-
CommitMsg string `json:"commit_msg"`
15-
IsLfs bool `json:"is_lfs"`
10+
Name string `json:"name"`
11+
Path string `json:"path"`
12+
Mode string `json:"mode"`
13+
Type string `json:"type"`
14+
Size int64 `json:"size"`
15+
SHA string `json:"sha"`
16+
URL string `json:"url"`
17+
CommitMsg string `json:"commit_msg"`
18+
CommitterDate time.Time `json:"committer_date"`
19+
IsLfs bool `json:"is_lfs"`
1620
}
1721

1822
// GitTreeResponse returns a git tree

routers/api/v1/repo/tree.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ func getDirectoryEntries(ctx *context.APIContext, folder string) ([]structs.GitE
5656
for _, c := range commits {
5757

5858
e := structs.GitEntry{
59-
Path: c.Entry.Name(),
60-
Mode: c.Entry.Mode().String(),
61-
Type: c.Entry.Type(),
62-
Size: c.Entry.Size(),
63-
SHA: c.Commit.ID.String(),
64-
URL: "",
65-
CommitMsg: c.Commit.CommitMessage,
59+
Name: c.Entry.Name(),
60+
Path: folder + "/" + c.Entry.Name(),
61+
Mode: c.Entry.Mode().String(),
62+
Type: c.Entry.Type(),
63+
Size: c.Entry.Size(),
64+
SHA: c.Commit.ID.String(),
65+
URL: "",
66+
CommitMsg: c.Commit.CommitMessage,
67+
CommitterDate: c.Commit.Committer.When,
6668
}
6769
//lfs pointer size is less than 1024
6870
if c.Entry.Size() <= 1024 {

0 commit comments

Comments
 (0)