]> source.dussan.org Git - gitea.git/commitdiff
submodule support and closed #478
authorlunnyxiao <xiaolunwen@gmail.com>
Mon, 22 Sep 2014 06:23:36 +0000 (14:23 +0800)
committerlunnyxiao <xiaolunwen@gmail.com>
Mon, 22 Sep 2014 06:23:36 +0000 (14:23 +0800)
modules/git/tree_entry.go
routers/repo/view.go
templates/repo/view_list.tmpl

index f65f332666e35f4ccfa45b3f49e2948223c1aea5..e403e93e3394392caae6d567ba5e493bde82db03 100644 (file)
@@ -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
index 41fdaba08c6ae66025f31de6fe0e3c256935c59b..77f17e7ae0965ee0e5bf81803d70e3f1cc86feee 100644 (file)
@@ -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})
index e8628306c97f37dd8aaf66d01dd6b81c7f983da3..41f7daf28dd693a5af95eab12827321cab794fdc 100644 (file)
                     <span class="octicon octicon-file-submodule"></span>
                 </td>
                 <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 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}}
             <td class="icon">
                     <span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span>
                 <td class="name">
                     <a href="{{$.BranchLink}}/{{$.TreePath}}{{$entry.Name}}" class="text-truncate">{{$entry.Name}}</a>
                 </td>
+                {{end}}
                 <td class="msg">
                     <a class="text-truncate" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a>
                 </td>
                 <td class="age">{{TimeSince $commit.Committer.When $.i18n.Lang}}</td>
-            {{end}}
             </tr>
         {{end}}
     </tbody>