From 7df60af60ed6d9606c5894c6512522dc91d0c247 Mon Sep 17 00:00:00 2001 From: lunnyxiao Date: Mon, 22 Sep 2014 14:23:36 +0800 Subject: [PATCH] submodule support and closed #478 --- modules/git/tree_entry.go | 2 +- routers/repo/view.go | 28 ++++++++++++++-------------- templates/repo/view_list.tmpl | 8 ++------ 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/modules/git/tree_entry.go b/modules/git/tree_entry.go index f65f332666..e403e93e33 100644 --- a/modules/git/tree_entry.go +++ b/modules/git/tree_entry.go @@ -84,7 +84,7 @@ type Entries []*TreeEntry var sorter = []func(t1, t2 *TreeEntry) bool{ func(t1, t2 *TreeEntry) bool { - return t1.IsDir() && !t2.IsDir() + return (t1.IsDir() || t1.IsSubModule()) && !t2.IsDir() && !t2.IsSubModule() }, func(t1, t2 *TreeEntry) bool { return t1.name < t2.name diff --git a/routers/repo/view.go b/routers/repo/view.go index 41fdaba08c..77f17e7ae0 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -10,7 +10,6 @@ import ( "path" "path/filepath" "strings" - "time" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" @@ -23,12 +22,10 @@ const ( ) type fakeCommit struct { - Id string - Summary string - Url string - Committer struct { - When time.Time - } + *git.Commit + + RefUrl string + RefId string } func Home(ctx *middleware.Context) { @@ -151,13 +148,16 @@ func Home(ctx *middleware.Context) { return } - commit := git.Commit{ - Tree: *tree, - Id: te.Id, - Committer: &git.Signature{ - When: time.Now(), - }, - CommitMessage: sm.Url, + c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name())) + if err != nil { + ctx.Handle(404, "GetCommitOfRelPath", err) + return + } + + commit := fakeCommit{ + Commit: c, + RefUrl: strings.TrimRight(sm.Url, ".git"), + RefId: te.Id.String(), } files = append(files, []interface{}{te, &commit}) diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl index e8628306c9..41f7daf28d 100644 --- a/templates/repo/view_list.tmpl +++ b/templates/repo/view_list.tmpl @@ -32,12 +32,8 @@ - {{$entry.Name}} @ {{ShortSha $commit.Id.String}} + {{$entry.Name}} @ {{ShortSha $commit.RefId}} - - {{$commit.Summary}} - - {{TimeSince $commit.Committer.When $.i18n.Lang}} {{else}} @@ -45,11 +41,11 @@ {{$entry.Name}} + {{end}} {{$commit.Summary}} {{TimeSince $commit.Committer.When $.i18n.Lang}} - {{end}} {{end}}