Skip to content

Commit e14eca3

Browse files
chore: add support for all VCS providers (#254)
* chore: add support for all VCS providers Signed-off-by: Sourya Vatsyayan <[email protected]> * add tests Signed-off-by: Sourya Vatsyayan <[email protected]> --------- Signed-off-by: Sourya Vatsyayan <[email protected]>
1 parent 965f861 commit e14eca3

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

command/repo/view/view.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ import (
1515
)
1616

1717
var VCSMap = map[string]string{
18-
"GITHUB": "gh",
19-
"GITLAB": "gl",
20-
"BITBUCKET": "bb",
18+
"GITHUB": "gh",
19+
"GITHUB_ENTERPRISE": "ghe",
20+
"GITLAB": "gl",
21+
"BITBUCKET": "bb",
22+
"BITBUCKET_DATACENTER": "bbdc",
23+
"ADS": "ads",
2124
}
2225

2326
type RepoViewOptions struct {

utils/remote_resolver.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,16 @@ func RepoArgumentResolver(arg string) ([]string, error) {
7979
switch argComponents[0] {
8080
case "gh", "github.com":
8181
argComponents[0] = "GITHUB"
82-
82+
case "ghe":
83+
argComponents[0] = "GITHUB_ENTERPRISE"
8384
case "gl", "gitlab.com":
8485
argComponents[0] = "GITLAB"
85-
8686
case "bb", "bitbucket.com":
8787
argComponents[0] = "BITBUCKET"
88+
case "bbdc":
89+
argComponents[0] = "BITBUCKET_DATACENTER"
90+
case "ads":
91+
argComponents[0] = "ADS"
8892
default:
8993
return argComponents, fmt.Errorf("VCSProvider `%s` not supported", argComponents[0])
9094
}

utils/remote_resolver_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ func TestResolveRemote(t *testing.T) {
2626
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "GITHUB"},
2727
wantErr: false,
2828
},
29+
{
30+
name: "valid github enterprise remote URL (short form)",
31+
repoArg: "ghe/deepsourcelabs/cli",
32+
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "GITHUB_ENTERPRISE"},
33+
wantErr: false,
34+
},
2935
{
3036
name: "valid gitlab remote URL",
3137
repoArg: "gitlab.com/deepsourcelabs/cli",
@@ -50,6 +56,18 @@ func TestResolveRemote(t *testing.T) {
5056
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "BITBUCKET"},
5157
wantErr: false,
5258
},
59+
{
60+
name: "valid bitbucket datacenter remote URL (short form)",
61+
repoArg: "bbdc/deepsourcelabs/cli",
62+
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "BITBUCKET_DATACENTER"},
63+
wantErr: false,
64+
},
65+
{
66+
name: "valid Azure Devops remote URL (short form)",
67+
repoArg: "ads/deepsourcelabs/cli",
68+
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "ADS"},
69+
wantErr: false,
70+
},
5371
{
5472
name: "invalid VCS provider",
5573
repoArg: "example.com/deepsourcelabs/cli",

0 commit comments

Comments
 (0)