Skip to content

Commit

Permalink
chore: add GitLab (public/private) subgroup test
Browse files Browse the repository at this point in the history
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 <guillaume@dagger.io>
  • Loading branch information
grouville committed May 31, 2024
1 parent 9fcec2a commit 1ac645b
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions vcs/vcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,40 @@ func TestRepoRootForImportPath(t *testing.T) {
Repo: "https://bitbucket.org/workspace/pkgname",
},
},
// GitLab public repo
{
"gitlab.com/testguigui1/dagger-public-sub/mywork/depth1/depth2",
&RepoRoot{
VCS: vcsGit,
Repo: "https://gitlab.com/testguigui1/dagger-public-sub/mywork.git",
},
},
{
"gitlab.com/testguigui1/dagger-public-sub/mywork/depth1/depth2",
&RepoRoot{
VCS: vcsGit,
Repo: "https://gitlab.com/testguigui1/dagger-public-sub/mywork.git",
},
},
// GitLab private repo
// behavior of private GitLab repos is different from public ones
// https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/middleware/go.rb#L114-126
// it relies on gitcredentials to authenticate
// TODO: rely on a dagger gitlab repo with a read-only PAT to test this
// {
// "gitlab.com/testguigui1/awesomesubgroup/mywork/depth1/depth2", // private subgroup
// &RepoRoot{
// VCS: vcsGit,
// Repo: "https://gitlab.com/testguigui1/awesomesubgroup.git", // false positive returned by GitLab for privacy purpose
// },
// },
// {
// "gitlab.com/testguigui1/awesomesubgroup/mywork.git/depth1/depth2", // private subgroup
// &RepoRoot{
// VCS: vcsGit,
// Repo: "https://gitlab.com/testguigui1/awesomesubgroup/mywork",
// },
// },
{
"bitbucket.org/workspace/pkgname/subdir",
&RepoRoot{
Expand Down

0 comments on commit 1ac645b

Please sign in to comment.