diff options
Diffstat (limited to 'vendor/code.gitea.io/git/submodule.go')
-rw-r--r-- | vendor/code.gitea.io/git/submodule.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vendor/code.gitea.io/git/submodule.go b/vendor/code.gitea.io/git/submodule.go index a0fe7b4a56..294df3986a 100644 --- a/vendor/code.gitea.io/git/submodule.go +++ b/vendor/code.gitea.io/git/submodule.go @@ -29,13 +29,12 @@ func NewSubModuleFile(c *Commit, refURL, refID string) *SubModuleFile { } } -// RefURL guesses and returns reference URL. -func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string { - if sf.refURL == "" { +func getRefURL(refURL, urlPrefix, parentPath string) string { + if refURL == "" { return "" } - url := strings.TrimSuffix(sf.refURL, ".git") + url := strings.TrimSuffix(refURL, ".git") // git://xxx/user/repo if strings.HasPrefix(url, "git://") { @@ -67,12 +66,21 @@ func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string { if strings.Contains(urlPrefix, url[i+1:j]) { return urlPrefix + url[j+1:] } + if strings.HasPrefix(url, "ssh://") || strings.HasPrefix(url, "git+ssh://") { + k := strings.Index(url[j+1:], "/") + return "http://" + url[i+1:j] + "/" + url[j+1:][k+1:] + } return "http://" + url[i+1:j] + "/" + url[j+1:] } return url } +// RefURL guesses and returns reference URL. +func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string { + return getRefURL(sf.refURL, urlPrefix, parentPath) +} + // RefID returns reference ID. func (sf *SubModuleFile) RefID() string { return sf.refID |