submodule support and closed #478

This commit is contained in:
lunnyxiao 2014-09-22 14:23:36 +08:00
parent 79ec08141a
commit 7df60af60e
3 changed files with 17 additions and 21 deletions

View file

@ -84,7 +84,7 @@ type Entries []*TreeEntry
var sorter = []func(t1, t2 *TreeEntry) bool{ var sorter = []func(t1, t2 *TreeEntry) bool{
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 { func(t1, t2 *TreeEntry) bool {
return t1.name < t2.name return t1.name < t2.name

View file

@ -10,7 +10,6 @@ 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"
@ -23,12 +22,10 @@ const (
) )
type fakeCommit struct { type fakeCommit struct {
Id string *git.Commit
Summary string
Url string RefUrl string
Committer struct { RefId string
When time.Time
}
} }
func Home(ctx *middleware.Context) { func Home(ctx *middleware.Context) {
@ -151,13 +148,16 @@ func Home(ctx *middleware.Context) {
return return
} }
commit := git.Commit{ c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
Tree: *tree, if err != nil {
Id: te.Id, ctx.Handle(404, "GetCommitOfRelPath", err)
Committer: &git.Signature{ return
When: time.Now(), }
},
CommitMessage: sm.Url, commit := fakeCommit{
Commit: c,
RefUrl: strings.TrimRight(sm.Url, ".git"),
RefId: te.Id.String(),
} }
files = append(files, []interface{}{te, &commit}) files = append(files, []interface{}{te, &commit})

View file

@ -32,12 +32,8 @@
<span class="octicon octicon-file-submodule"></span> <span class="octicon octicon-file-submodule"></span>
</td> </td>
<td class="name"> <td class="name">
<a href="{{$commit.CommitMessage}}" class="text-truncate">{{$entry.Name}}</a> @ <a href="{{$commit.CommitMessage}}/commit/{{$commit.Id}}">{{ShortSha $commit.Id.String}}</a> <a href="{{$commit.RefUrl}}" class="text-truncate">{{$entry.Name}}</a> @ <a href="{{$commit.RefUrl}}/commit/{{$commit.RefId}}">{{ShortSha $commit.RefId}}</a>
</td> </td>
<td class="msg">
<a class="text-truncate" href="{{$commit.CommitMessage}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a>
</td>
<td class="age">{{TimeSince $commit.Committer.When $.i18n.Lang}}</td>
{{else}} {{else}}
<td class="icon"> <td class="icon">
<span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span> <span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span>
@ -45,11 +41,11 @@
<td class="name"> <td class="name">
<a href="{{$.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a> <a href="{{$.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
</td> </td>
{{end}}
<td class="msg"> <td class="msg">
<a class="text-truncate" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a> <a class="text-truncate" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a>
</td> </td>
<td class="age">{{TimeSince $commit.Committer.When $.i18n.Lang}}</td> <td class="age">{{TimeSince $commit.Committer.When $.i18n.Lang}}</td>
{{end}}
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>