Skip to content

Commit

Permalink
Fixes incorrect url for submodules that specify the remote port
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Governatore committed Jan 26, 2018
1 parent 6798d0f commit b2c17ef
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 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,22 @@ 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:]
} else {
return urlPrefix + url[j+1 + port+1:]
}
}
return "http://" + url[i+1:j] + "/" + url[j+1:]
}
Expand Down

0 comments on commit b2c17ef

Please sign in to comment.