Skip to content

Commit

Permalink
Merge pull request #101 from jjv/fix-username-from-url-to-git
Browse files Browse the repository at this point in the history
Use parsed username also with ssh for Git
  • Loading branch information
Songmu authored Apr 26, 2019
2 parents d0b6286 + e389c21 commit 1ba473d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion url.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func NewURL(ref string) (*url.URL, error) {
}

func ConvertGitURLHTTPToSSH(url *url.URL) (*url.URL, error) {
sshURL := fmt.Sprintf("ssh://git@%s%s", url.Host, url.Path)
user := "git";
if url.User != nil {
user = url.User.Username()
}
sshURL := fmt.Sprintf("ssh://%s@%s%s", user, url.Host, url.Path)
return url.Parse(sshURL)
}

Expand Down

0 comments on commit 1ba473d

Please sign in to comment.