Skip to content

Commit 2d41774

Browse files
author
grouville
committed
chore: add GitLab (public/private) subgroup test
Weird behavior encountered on GitLab's subgroups in private mode. After investigation, it turns out that GitLab conceils the existence of the nested project when unauthenticated: https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/middleware/go.rb#L114-126. The current behavior of the library is to rely on the `git ls-remote -q` command when the path contains a `.git`, which relies on gitcredentials for auth. The exact behavior is detailed in this comment: golang/go#26232 (comment) Interesting link regrouping all Go private repo issues: golang/go#29953 Signed-off-by: grouville <[email protected]>
1 parent 9adb0b1 commit 2d41774

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

vcs_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,40 @@ func TestRepoRootForImportPath(t *testing.T) {
102102
Repo: "https://bitbucket.org/workspace/pkgname",
103103
},
104104
},
105+
// GitLab public repo
106+
{
107+
"gitlab.com/testguigui1/dagger-public-sub/mywork/depth1/depth2",
108+
&RepoRoot{
109+
VCS: vcsGit,
110+
Repo: "https://gitlab.com/testguigui1/dagger-public-sub/mywork.git",
111+
},
112+
},
113+
{
114+
"gitlab.com/testguigui1/dagger-public-sub/mywork/depth1/depth2",
115+
&RepoRoot{
116+
VCS: vcsGit,
117+
Repo: "https://gitlab.com/testguigui1/dagger-public-sub/mywork.git",
118+
},
119+
},
120+
// GitLab private repo
121+
// behavior of private GitLab repos is different from public ones
122+
// https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/middleware/go.rb#L114-126
123+
// it relies on gitcredentials to authenticate
124+
// TODO: rely on a dagger gitlab repo with a read-only PAT to test this
125+
// {
126+
// "gitlab.com/testguigui1/awesomesubgroup/mywork/depth1/depth2", // private subgroup
127+
// &RepoRoot{
128+
// VCS: vcsGit,
129+
// Repo: "https://gitlab.com/testguigui1/awesomesubgroup.git", // false positive returned by GitLab for privacy purpose
130+
// },
131+
// },
132+
// {
133+
// "gitlab.com/testguigui1/awesomesubgroup/mywork.git/depth1/depth2", // private subgroup
134+
// &RepoRoot{
135+
// VCS: vcsGit,
136+
// Repo: "https://gitlab.com/testguigui1/awesomesubgroup/mywork",
137+
// },
138+
// },
105139
{
106140
"bitbucket.org/workspace/pkgname/subdir",
107141
&RepoRoot{

0 commit comments

Comments
 (0)