summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-08-07 13:01:04 +1000
committerGitHub <noreply@github.com>2022-08-07 13:01:04 +1000
commit71a9389ca4311d8c36b7d4a2ba0e6926e8a767a8 (patch)
treeae8852d78d0abf7886482ab1d503ef3a38e1309a /pkg
parentb77f3160f1c1e2d9a45c8468ef465b9631f2edf3 (diff)
parent4db22aec0e9de2b580580b19751d87fe3272d590 (diff)
Merge pull request #2087 from xxdavid/bitbucket_custom_username
Diffstat (limited to 'pkg')
-rw-r--r--pkg/commands/hosting_service/definitions.go7
-rw-r--r--pkg/commands/hosting_service/hosting_service_test.go9
2 files changed, 14 insertions, 2 deletions
diff --git a/pkg/commands/hosting_service/definitions.go b/pkg/commands/hosting_service/definitions.go
index 04d496aa8..c53ee0507 100644
--- a/pkg/commands/hosting_service/definitions.go
+++ b/pkg/commands/hosting_service/definitions.go
@@ -24,8 +24,11 @@ var bitbucketServiceDef = ServiceDefinition{
pullRequestURLIntoDefaultBranch: "/pull-requests/new?source={{.From}}&t=1",
pullRequestURLIntoTargetBranch: "/pull-requests/new?source={{.From}}&dest={{.To}}&t=1",
commitURL: "/commits/{{.CommitSha}}",
- regexStrings: defaultUrlRegexStrings,
- repoURLTemplate: defaultRepoURLTemplate,
+ regexStrings: []string{
+ `^(?:https?|ssh)://.*/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
+ `^.*@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
+ },
+ repoURLTemplate: defaultRepoURLTemplate,
}
var gitLabServiceDef = ServiceDefinition{
diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go
index 0c926117d..b92daa98d 100644
--- a/pkg/commands/hosting_service/hosting_service_test.go
+++ b/pkg/commands/hosting_service/hosting_service_test.go
@@ -116,6 +116,15 @@ func TestGetPullRequestURL(t *testing.T) {
},
},
{
+ testName: "Opens a link to new pull request on bitbucket with a custom SSH username",
+ from: "feature/profile-page",
+ remoteUrl: "john@bitbucket.org:johndoe/social_network.git",
+ test: func(url string, err error) {
+ assert.NoError(t, err)
+ assert.Equal(t, "https://bitbucket.org/johndoe/social_network/pull-requests/new?source=feature%2Fprofile-page&t=1", url)
+ },
+ },
+ {
testName: "Opens a link to new pull request on Azure DevOps (SSH)",
from: "feature/new",
remoteUrl: "git@ssh.dev.azure.com:v3/myorg/myproject/myrepo",