diff options
author | Andrew <x.and.i.rew.e@gmail.com> | 2023-04-03 12:10:30 +1000 |
---|---|---|
committer | Andrew <x.and.i.rew.e@gmail.com> | 2023-04-03 12:10:30 +1000 |
commit | 298dae23e8395712a6644d860b9aa983477fcc33 (patch) | |
tree | b3e2c45863025ca8d77fd6494156c25703398001 | |
parent | a02b54e1b7e7e8dd8bc1958c11ef4ee4df459ea4 (diff) |
fix: generalize parsing of ssh git urls
-rw-r--r-- | pkg/commands/hosting_service/definitions.go | 2 | ||||
-rw-r--r-- | pkg/commands/hosting_service/hosting_service_test.go | 10 |
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", |