Skip to content

Commit 2c11506

Browse files
committed
Fix to support creating merge requests for Gitlab/Github repositories cloned with an SSH config alias
1 parent 06426b2 commit 2c11506

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/commands/hosting_service/definitions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package hosting_service
44
// at https://regex101.com using the flavor Golang
55
var defaultUrlRegexStrings = []string{
66
`^(?:https?|ssh)://[^/]+/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
7-
`^.*?@.*:/*(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
7+
`^(.*?@)?.*:/*(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
88
}
99
var defaultRepoURLTemplate = "https://{{.webDomain}}/{{.owner}}/{{.repo}}"
1010

pkg/commands/hosting_service/hosting_service_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ func TestGetPullRequestURL(t *testing.T) {
133133
assert.Equal(t, "https://gitlab.com/peter/calculator/-/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2Fui", url)
134134
},
135135
},
136+
{
137+
testName: "Opens a link to new pull request on gitlab with custom SSH config alias and a corresponding service config",
138+
from: "feature/ui",
139+
remoteUrl: "gitlab:peter/calculator.git",
140+
configServiceDomains: map[string]string{"gitlab": "gitlab:gitlab.com"},
141+
test: func(url string, err error) {
142+
assert.NoError(t, err)
143+
assert.Equal(t, "https://gitlab.com/peter/calculator/-/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2Fui", url)
144+
},
145+
},
136146
{
137147
testName: "Opens a link to new pull request on gitlab with extra slash removed",
138148
from: "feature/ui",

0 commit comments

Comments
 (0)