diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-26 17:01:06 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-12-26 17:05:05 +1100 |
commit | 4df003cc4455adc7004c5da4bbcbc4a8b69d47c3 (patch) | |
tree | 076247af9257da18ecdaccd3df5a3386045630ec | |
parent | d9db5ccfbe1407f8a2cd2587aff3044c272e175e (diff) |
handle ssh protocol
-rw-r--r-- | pkg/commands/pull_request.go | 4 | ||||
-rw-r--r-- | pkg/commands/pull_request_test.go | 9 |
2 files changed, 11 insertions, 2 deletions
diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go index 186ed09b3..ed065bbec 100644 --- a/pkg/commands/pull_request.go +++ b/pkg/commands/pull_request.go @@ -12,8 +12,8 @@ import ( // if you want to make a custom regex for a given service feel free to test it out // at regoio.herokuapp.com var defaultUrlRegexStrings = []string{ - `^https?://.*/(?P<owner>.*)/(?P<repo>.*?)(\.git)?$`, - `^git@.*:(?P<owner>.*)/(?P<repo>.*?)(\.git)?$`, + `^(?:https?|ssh)://.*/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`, + `^git@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`, } // Service is a service that repository is on (Github, Bitbucket, ...) diff --git a/pkg/commands/pull_request_test.go b/pkg/commands/pull_request_test.go index b6ec527de..6195dff4c 100644 --- a/pkg/commands/pull_request_test.go +++ b/pkg/commands/pull_request_test.go @@ -36,6 +36,15 @@ func TestGetRepoInfoFromURL(t *testing.T) { }, { NewGithubService("github.com", "github.com"), + "Returns repository information for ssh remote url", + "ssh://git@github.com/petersmith/super_calculator", + func(repoInfo *RepoInformation) { + assert.EqualValues(t, repoInfo.Owner, "petersmith") + assert.EqualValues(t, repoInfo.Repository, "super_calculator") + }, + }, + { + NewGithubService("github.com", "github.com"), "Returns repository information for http remote url", "https://my_username@bitbucket.org/johndoe/social_network.git", func(repoInfo *RepoInformation) { |