Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions command/repo/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ import (
)

var VCSMap = map[string]string{
"GITHUB": "gh",
"GITLAB": "gl",
"BITBUCKET": "bb",
"GITHUB": "gh",
"GITHUB_ENTERPRISE": "ghe",
"GITLAB": "gl",
"BITBUCKET": "bb",
"BITBUCKET_DATACENTER": "bbdc",
"ADS": "ads",
}

type RepoViewOptions struct {
Expand Down
8 changes: 6 additions & 2 deletions utils/remote_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ func RepoArgumentResolver(arg string) ([]string, error) {
switch argComponents[0] {
case "gh", "github.com":
argComponents[0] = "GITHUB"

case "ghe":
argComponents[0] = "GITHUB_ENTERPRISE"
case "gl", "gitlab.com":
argComponents[0] = "GITLAB"

case "bb", "bitbucket.com":
argComponents[0] = "BITBUCKET"
case "bbdc":
argComponents[0] = "BITBUCKET_DATACENTER"
case "ads":
argComponents[0] = "ADS"
default:
return argComponents, fmt.Errorf("VCSProvider `%s` not supported", argComponents[0])
}
Expand Down
18 changes: 18 additions & 0 deletions utils/remote_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ func TestResolveRemote(t *testing.T) {
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "GITHUB"},
wantErr: false,
},
{
name: "valid github enterprise remote URL (short form)",
repoArg: "ghe/deepsourcelabs/cli",
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "GITHUB_ENTERPRISE"},
wantErr: false,
},
{
name: "valid gitlab remote URL",
repoArg: "gitlab.com/deepsourcelabs/cli",
Expand All @@ -50,6 +56,18 @@ func TestResolveRemote(t *testing.T) {
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "BITBUCKET"},
wantErr: false,
},
{
name: "valid bitbucket datacenter remote URL (short form)",
repoArg: "bbdc/deepsourcelabs/cli",
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "BITBUCKET_DATACENTER"},
wantErr: false,
},
{
name: "valid Azure Devops remote URL (short form)",
repoArg: "ads/deepsourcelabs/cli",
want: &RemoteData{Owner: "deepsourcelabs", RepoName: "cli", VCSProvider: "ADS"},
wantErr: false,
},
{
name: "invalid VCS provider",
repoArg: "example.com/deepsourcelabs/cli",
Expand Down