mirror of
https://github.com/go-gitea/gitea
synced 2024-11-26 07:12:48 +01:00
Handle submodules without a .gitmodules entry - fix #1023
This commit is contained in:
parent
5e763baa12
commit
5d5d774e03
4 changed files with 15 additions and 3 deletions
|
@ -88,11 +88,11 @@ func (c *Commit) GetCommitOfRelPath(relPath string) (*Commit, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
|
func (c *Commit) GetSubModule(entryname string) (*SubModule, error) {
|
||||||
moduels, err := c.GetSubModules()
|
modules, err := c.GetSubModules()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return moduels[entryname], nil
|
return modules[entryname], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Commit) GetSubModules() (map[string]*SubModule, error) {
|
func (c *Commit) GetSubModules() (map[string]*SubModule, error) {
|
||||||
|
|
|
@ -31,6 +31,10 @@ func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile {
|
||||||
|
|
||||||
// RefUrl guesses and returns reference URL.
|
// RefUrl guesses and returns reference URL.
|
||||||
func (sf *SubModuleFile) RefUrl() string {
|
func (sf *SubModuleFile) RefUrl() string {
|
||||||
|
if sf.refUrl == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
url := strings.TrimSuffix(sf.refUrl, ".git")
|
url := strings.TrimSuffix(sf.refUrl, ".git")
|
||||||
|
|
||||||
// git://xxx/user/repo
|
// git://xxx/user/repo
|
||||||
|
|
|
@ -141,13 +141,17 @@ func Home(ctx *middleware.Context) {
|
||||||
ctx.Handle(500, "GetSubModule", err)
|
ctx.Handle(500, "GetSubModule", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
smUrl := ""
|
||||||
|
if sm != nil {
|
||||||
|
smUrl = sm.Url
|
||||||
|
}
|
||||||
|
|
||||||
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(500, "GetCommitOfRelPath", err)
|
ctx.Handle(500, "GetCommitOfRelPath", err)
|
||||||
return
|
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
|
ctx.Data["Files"] = files
|
||||||
|
|
|
@ -39,7 +39,11 @@
|
||||||
<span class="octicon octicon-file-submodule"></span>
|
<span class="octicon octicon-file-submodule"></span>
|
||||||
</td>
|
</td>
|
||||||
<td class="name">
|
<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>
|
<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>
|
</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td class="icon">
|
<td class="icon">
|
||||||
|
|
Loading…
Reference in a new issue