|
|
@ -10,6 +10,7 @@ import ( |
|
|
|
"path" |
|
|
|
"path" |
|
|
|
"path/filepath" |
|
|
|
"path/filepath" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/gogits/gogs/modules/base" |
|
|
|
"github.com/gogits/gogs/modules/base" |
|
|
|
"github.com/gogits/gogs/modules/git" |
|
|
|
"github.com/gogits/gogs/modules/git" |
|
|
@ -21,6 +22,15 @@ const ( |
|
|
|
HOME base.TplName = "repo/home" |
|
|
|
HOME base.TplName = "repo/home" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type fakeCommit struct { |
|
|
|
|
|
|
|
Id string |
|
|
|
|
|
|
|
Summary string |
|
|
|
|
|
|
|
Url string |
|
|
|
|
|
|
|
Committer struct { |
|
|
|
|
|
|
|
When time.Time |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func Home(ctx *middleware.Context) { |
|
|
|
func Home(ctx *middleware.Context) { |
|
|
|
ctx.Data["Title"] = ctx.Repo.Repository.Name |
|
|
|
ctx.Data["Title"] = ctx.Repo.Repository.Name |
|
|
|
|
|
|
|
|
|
|
@ -127,13 +137,31 @@ func Home(ctx *middleware.Context) { |
|
|
|
files := make([][]interface{}, 0, len(entries)) |
|
|
|
files := make([][]interface{}, 0, len(entries)) |
|
|
|
|
|
|
|
|
|
|
|
for _, te := range entries { |
|
|
|
for _, te := range entries { |
|
|
|
|
|
|
|
if te.Type != git.COMMIT { |
|
|
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) |
|
|
|
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
ctx.Handle(404, "GetCommitOfRelPath", err) |
|
|
|
ctx.Handle(404, "GetCommitOfRelPath", err) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
files = append(files, []interface{}{te, c}) |
|
|
|
files = append(files, []interface{}{te, c}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sm, err := ctx.Repo.Commit.GetSubModule(path.Join(treename, te.Name())) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
ctx.Handle(404, "GetSubModule", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
commit := git.Commit{ |
|
|
|
|
|
|
|
Tree: *tree, |
|
|
|
|
|
|
|
Id: te.Id, |
|
|
|
|
|
|
|
Committer: &git.Signature{ |
|
|
|
|
|
|
|
When: time.Now(), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
CommitMessage: sm.Url, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
files = append(files, []interface{}{te, &commit}) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ctx.Data["Files"] = files |
|
|
|
ctx.Data["Files"] = files |
|
|
|