summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author无闻 <u@gogs.io>2015-03-10 00:05:45 -0400
committer无闻 <u@gogs.io>2015-03-10 00:05:45 -0400
commit6abbea4f3d094a4f947115a81ce6cb96aa20e36e (patch)
tree953cddb2e3194926266ee9f9e28b3ee235be11a1
parent5e763baa12e346f8eb577073399068802fa5d67a (diff)
parent5d5d774e03ea02b29ff2bd25e1bf63ce82851fc5 (diff)
downloadgitea-6abbea4f3d094a4f947115a81ce6cb96aa20e36e.tar.gz
gitea-6abbea4f3d094a4f947115a81ce6cb96aa20e36e.zip
Merge pull request #1027 from FiloSottile/master
Handle submodules without a .gitmodules entry - fix #1023
-rw-r--r--modules/git/commit.go4
-rw-r--r--modules/git/submodule.go4
-rw-r--r--routers/repo/view.go6
-rw-r--r--templates/repo/view_list.tmpl4
4 files changed, 15 insertions, 3 deletions
diff --git a/modules/git/commit.go b/modules/git/commit.go
index d2d373da12..4e254dcec1 100644
--- a/modules/git/commit.go
+++ b/modules/git/commit.go
@@ -88,11 +88,11 @@ func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error) {
}
func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
- moduels, err := c.GetSubModules()
+ modules, err := c.GetSubModules()
if err != nil {
return nil, err
}
- return moduels[entryname], nil
+ return modules[entryname], nil
}
func (c *Commit) GetSubModules() (map[string]*SubModule, error) {
diff --git a/modules/git/submodule.go b/modules/git/submodule.go
index 6927f8cbad..0c7c2696c3 100644
--- a/modules/git/submodule.go
+++ b/modules/git/submodule.go
@@ -31,6 +31,10 @@ func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile {
// RefUrl guesses and returns reference URL.
func (sf *SubModuleFile) RefUrl() string {
+ if sf.refUrl == "" {
+ return ""
+ }
+
url := strings.TrimSuffix(sf.refUrl, ".git")
// git://xxx/user/repo
diff --git a/routers/repo/view.go b/routers/repo/view.go
index cfe0fa010c..2a36db6b42 100644
--- a/routers/repo/view.go
+++ b/routers/repo/view.go
@@ -141,13 +141,17 @@ func Home(ctx *middleware.Context) {
ctx.Handle(500, "GetSubModule", err)
return
}
+ smUrl := ""
+ if sm != nil {
+ smUrl = sm.Url
+ }
c, err := ctx.Repo.Commit.GetCommitOfRelPath(filepath.Join(treePath, te.Name()))
if err != nil {
ctx.Handle(500, "GetCommitOfRelPath", err)
return
}
- files = append(files, []interface{}{te, git.NewSubModuleFile(c, sm.Url, te.Id.String())})
+ files = append(files, []interface{}{te, git.NewSubModuleFile(c, smUrl, te.Id.String())})
}
}
ctx.Data["Files"] = files
diff --git a/templates/repo/view_list.tmpl b/templates/repo/view_list.tmpl
index 06536b4728..f51c10025a 100644
--- a/templates/repo/view_list.tmpl
+++ b/templates/repo/view_list.tmpl
@@ -39,7 +39,11 @@
<span class="octicon octicon-file-submodule"></span>
</td>
<td class="name">
+ {{if $commit.RefUrl}}
<a href="{{$commit.RefUrl}}" class="text-truncate">{{$entry.Name}}</a> @ <a href="{{$commit.RefUrl}}/commit/{{$commit.RefId}}">{{ShortSha $commit.RefId}}</a>
+ {{else}}
+ {{$entry.Name}} @ {{ShortSha $commit.RefId}}
+ {{end}}
</td>
{{else}}
<td class="icon">