зеркало из https://github.com/go-gitea/git.git
Fixed incorrect creation of relative submodule URL (#14)
According to git submodule documentation base path for relative submodule URL is parent repository's root - not submodule "mount point". So it's necessary to know "path" of parent repository to create correct submodule URL.
This commit is contained in:
Родитель
1f1117c396
Коммит
c61be7813a
10
submodule.go
10
submodule.go
|
@ -29,7 +29,7 @@ func NewSubModuleFile(c *Commit, refUrl, refId string) *SubModuleFile {
|
|||
|
||||
// FIXME: remove import of setting
|
||||
// RefUrl guesses and returns reference URL.
|
||||
func (sf *SubModuleFile) RefUrl(urlPrefix string) string {
|
||||
func (sf *SubModuleFile) RefUrl(urlPrefix string, parentPath string) string {
|
||||
if sf.refUrl == "" {
|
||||
return ""
|
||||
}
|
||||
|
@ -46,6 +46,14 @@ func (sf *SubModuleFile) RefUrl(urlPrefix string) string {
|
|||
return url
|
||||
}
|
||||
|
||||
// relative url prefix check (according to git submodule documentation)
|
||||
if strings.HasPrefix(url, "./") || strings.HasPrefix(url, "../") {
|
||||
// ...construct and return correct submodule url here...
|
||||
idx := strings.LastIndex(parentPath, "/src/")
|
||||
rel_url := strings.TrimSuffix(urlPrefix, "/") + parentPath[:idx] + "/" + url
|
||||
return rel_url
|
||||
}
|
||||
|
||||
// sysuser@xxx:user/repo
|
||||
i := strings.Index(url, "@")
|
||||
j := strings.LastIndex(url, ":")
|
||||
|
|
Загрузка…
Ссылка в новой задаче