Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pkg/commands/hosting_service/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package hosting_service
// at https://regex101.com using the flavor Golang
var defaultUrlRegexStrings = []string{
`^(?:https?|ssh)://[^/]+/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^.*?@.*:/*(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^(.*?@)?.*:/*(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
}
var defaultRepoURLTemplate = "https://{{.webDomain}}/{{.owner}}/{{.repo}}"

Expand Down
20 changes: 20 additions & 0 deletions pkg/commands/hosting_service/hosting_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ func TestGetPullRequestURL(t *testing.T) {
assert.Equal(t, "https://github.com/peter/calculator/compare/feature%2Fsum-operation?expand=1", url)
},
},
{
testName: "Opens a link to new pull request on github custom SSH config alias and a corresponding service config",
from: "feature/sum-operation",
remoteUrl: "github:peter/calculator.git",
configServiceDomains: map[string]string{"github": "github:github.com"},
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://github.com/peter/calculator/compare/feature%2Fsum-operation?expand=1", url)
},
},
{
testName: "Opens a link to new pull request on github with extra slash removed",
from: "feature/sum-operation",
Expand Down Expand Up @@ -133,6 +143,16 @@ func TestGetPullRequestURL(t *testing.T) {
assert.Equal(t, "https://gitlab.com/peter/calculator/-/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2Fui", url)
},
},
{
testName: "Opens a link to new pull request on gitlab with custom SSH config alias and a corresponding service config",
from: "feature/ui",
remoteUrl: "gitlab:peter/calculator.git",
configServiceDomains: map[string]string{"gitlab": "gitlab:gitlab.com"},
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://gitlab.com/peter/calculator/-/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2Fui", url)
},
},
{
testName: "Opens a link to new pull request on gitlab with extra slash removed",
from: "feature/ui",
Expand Down