summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew <x.and.i.rew.e@gmail.com>2023-04-03 12:10:30 +1000
committerAndrew <x.and.i.rew.e@gmail.com>2023-04-03 12:10:30 +1000
commit298dae23e8395712a6644d860b9aa983477fcc33 (patch)
treeb3e2c45863025ca8d77fd6494156c25703398001
parenta02b54e1b7e7e8dd8bc1958c11ef4ee4df459ea4 (diff)
fix: generalize parsing of ssh git urls
-rw-r--r--pkg/commands/hosting_service/definitions.go2
-rw-r--r--pkg/commands/hosting_service/hosting_service_test.go10
2 files changed, 11 insertions, 1 deletions
diff --git a/pkg/commands/hosting_service/definitions.go b/pkg/commands/hosting_service/definitions.go
index 39a554c3f..8dab166aa 100644
--- a/pkg/commands/hosting_service/definitions.go
+++ b/pkg/commands/hosting_service/definitions.go
@@ -4,7 +4,7 @@ package hosting_service
// at regoio.herokuapp.com
var defaultUrlRegexStrings = []string{
`^(?:https?|ssh)://[^/]+/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
- `^git@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
+ `^.*?@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
}
var defaultRepoURLTemplate = "https://{{.webDomain}}/{{.owner}}/{{.repo}}"
diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go
index d67d94ed8..a3b128b01 100644
--- a/pkg/commands/hosting_service/hosting_service_test.go
+++ b/pkg/commands/hosting_service/hosting_service_test.go
@@ -87,6 +87,16 @@ func TestGetPullRequestURL(t *testing.T) {
},
},
{
+ testName: "Opens a link to new pull request on github with specific target branch (different git username)",
+ from: "feature/sum-operation",
+ to: "feature/operations",
+ remoteUrl: "ssh://org-12345@github.com:peter/calculator.git",
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://github.com/peter/calculator/compare/feature%2Foperations...feature%2Fsum-operation?expand=1", url)
+ },
+ },
+ {
testName: "Opens a link to new pull request on github with https remote url with specific target branch",
from: "feature/sum-operation",
to: "feature/operations",