From 1ac645b83b98ea64d13899ad5381db383b8557e9 Mon Sep 17 00:00:00 2001 From: grouville Date: Thu, 9 May 2024 15:14:49 -0700 Subject: [PATCH] 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: https://github.com/golang/go/issues/26232#issuecomment-424306912 Interesting link regrouping all Go private repo issues: https://github.com/golang/go/issues/29953 Signed-off-by: grouville --- vcs/vcs_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/vcs/vcs_test.go b/vcs/vcs_test.go index fe544d59d8..d64a60ce07 100644 --- a/vcs/vcs_test.go +++ b/vcs/vcs_test.go @@ -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{