Skip to content
This repository has been archived by the owner on Apr 12, 2019. It is now read-only.

Fixes incorrect URL for submodules that specify the remote port #108

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

package git

import "strings"
import (
"strings"
"strconv"
)

// SubModule submodule is a reference on git repository
type SubModule struct {
Expand Down Expand Up @@ -58,14 +61,21 @@ func (sf *SubModuleFile) RefURL(urlPrefix string, parentPath string) string {
}

// sysuser@xxx:user/repo
// or
// sysuser@xxx:port/user/repo
i := strings.Index(url, "@")
j := strings.LastIndex(url, ":")

// Only process when i < j because git+ssh://[email protected]/npploader.git
if i > -1 && j > -1 && i < j {
// fix problem with reverse proxy works only with local server
if strings.Contains(urlPrefix, url[i+1:j]) {
return urlPrefix + url[j+1:]
port := strings.Index(url[j+1:], "/")
_, err := strconv.ParseInt(url[j+1:j+1 + port],10,16)
if err != nil {
return urlPrefix + url[j+1:]
}
return urlPrefix + url[j+1 + port+1:]
}
return "http://" + url[i+1:j] + "/" + url[j+1:]
}
Expand Down