You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2023/11/10 09:30:47 UTC
(incubator-devlake) branch release-v0.19 updated: fix: remove gitlab cloud non-own organization repos (#6438) (#6439)
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch release-v0.19
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.19 by this push:
new 06ab72e85 fix: remove gitlab cloud non-own organization repos (#6438) (#6439)
06ab72e85 is described below
commit 06ab72e85d4d213bb6cb7ef952f72232e877048b
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Fri Nov 10 17:30:43 2023 +0800
fix: remove gitlab cloud non-own organization repos (#6438) (#6439)
* fix: remove gitlab cloud non-own organization repos
* fix: remove useless code
Co-authored-by: abeizn <zi...@merico.dev>
---
backend/plugins/gitlab/api/remote.go | 6 +++++-
backend/plugins/gitlab/models/connection.go | 1 +
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/backend/plugins/gitlab/api/remote.go b/backend/plugins/gitlab/api/remote.go
index 1f62fe665..bf431dc08 100644
--- a/backend/plugins/gitlab/api/remote.go
+++ b/backend/plugins/gitlab/api/remote.go
@@ -84,7 +84,11 @@ 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)
+ 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"