forked from profclems/glab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support deep nested subgroups in repo path
`glab` initially only suppported repo paths in the format HOST/OWNER/REPO and HOST/GROUP/NAMESPACE/REPO. Knowing that GitLab supports deep nested subgroups, this adds supports for deep nested groups. Resolves profclems#609
- Loading branch information
Showing
2 changed files
with
56 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -177,6 +177,13 @@ func Test_repoFromURL(t *testing.T) { | |
host: "gitlab.com", | ||
err: nil, | ||
}, | ||
{ | ||
name: "gitlab.com deep nested", | ||
input: "git://gitlab.com/owner/subgroup/subgroup1/subgroup2/subgroup3/namespace/repo.git", | ||
result: "owner/subgroup/subgroup1/subgroup2/subgroup3/namespace/repo", | ||
host: "gitlab.com", | ||
err: nil, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|
@@ -245,8 +252,8 @@ hosts: | |
}, | ||
{ | ||
name: "group namespace", | ||
input: "a/b/c/d", | ||
wantHost: "a", | ||
input: "example.org/b/c/d", | ||
wantHost: "example.org", | ||
wantOwner: "b/c", | ||
wantName: "d", | ||
wantFullname: "b/c/d", | ||
|
@@ -270,6 +277,11 @@ hosts: | |
input: "a/", | ||
wantErr: errors.New(`expected the "[HOST/]OWNER/[NAMESPACE/]REPO" format, got "a/"`), | ||
}, | ||
{ | ||
name: "blank value inner", | ||
input: "a//c", | ||
wantErr: errors.New(`expected the "[HOST/]OWNER/[NAMESPACE/]REPO" format, got "a//c"`), | ||
}, | ||
{ | ||
name: "with hostname", | ||
input: "example.org/OWNER/REPO", | ||
|
@@ -314,6 +326,17 @@ hosts: | |
wantGroup: "", | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "Deep Nested Groups", | ||
input: "[email protected]:GROUP/SUBGROUP1/SUBGROUP2/SUBGROUP3/SUBGROUP4/REPO.git", | ||
wantHost: "example.org", | ||
wantOwner: "GROUP/SUBGROUP1/SUBGROUP2/SUBGROUP3/SUBGROUP4", | ||
wantName: "REPO", | ||
wantFullname: "GROUP/SUBGROUP1/SUBGROUP2/SUBGROUP3/SUBGROUP4/REPO", | ||
wantNamespace: "SUBGROUP1/SUBGROUP2/SUBGROUP3/SUBGROUP4", | ||
wantGroup: "GROUP", | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "invalid URL", | ||
input: "[email protected]/%/url", | ||
|
@@ -386,6 +409,11 @@ func TestFullNameFromURL(t *testing.T) { | |
want: "owner/namespace/repo", | ||
wantErr: nil, | ||
}, | ||
{ | ||
remoteURL: "[email protected]:owner/subgroup/subgroup1/subgroup2/subgroup3/namespace/repo.git", | ||
want: "owner/subgroup/subgroup1/subgroup2/subgroup3/namespace/repo", | ||
wantErr: nil, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.remoteURL, func(t *testing.T) { | ||
|