This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch remove-gitlab-cloud-no-owner-org-repos
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to
refs/heads/remove-gitlab-cloud-no-owner-org-repos by this push:
new 9aa342da5 fix: remove gitlab cloud non-own organization repos
9aa342da5 is described below
commit 9aa342da5ba23f06a63071e5ed9aaa939bd16b0a
Author: abeizn <[email protected]>
AuthorDate: Fri Nov 10 16:24:10 2023 +0800
fix: remove gitlab cloud non-own organization repos
---
backend/plugins/gitlab/api/remote.go | 7 ++++++-
backend/plugins/gitlab/models/connection.go | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/gitlab/api/remote.go
b/backend/plugins/gitlab/api/remote.go
index d86cd216c..48f539db9 100644
--- a/backend/plugins/gitlab/api/remote.go
+++ b/backend/plugins/gitlab/api/remote.go
@@ -83,7 +83,12 @@ func RemoteScopes(input *plugin.ApiResourceInput)
(*plugin.ApiResourceOutput, er
var resBody []models.GitlabApiProject
if gid == "" {
var resProjects []models.GitlabApiProject
- res, err = apiClient.Get("/projects", query,
nil)
+ fmt.Printf("%v", connection.Endpoint)
+ if connection.Endpoint ==
models.GitlabCloudEndPoint {
+ res, err =
apiClient.Get(fmt.Sprintf("users/%d/projects", apiClient.GetData("UserId")),
query, nil)
+ } else {
+ res, err = apiClient.Get("/projects",
query, nil)
+ }
if err != nil {
return nil, err
}
diff --git a/backend/plugins/gitlab/models/connection.go
b/backend/plugins/gitlab/models/connection.go
index ec3fcd0eb..48d33d069 100644
--- a/backend/plugins/gitlab/models/connection.go
+++ b/backend/plugins/gitlab/models/connection.go
@@ -33,6 +33,7 @@ type GitlabConn struct {
api.AccessToken `mapstructure:",squash"`
}
+const GitlabCloudEndPoint string = "https://gitlab.com/api/v4/"
const GitlabApiClientData_UserId string = "UserId"
const GitlabApiClientData_ApiVersion string = "ApiVersion"