This is an automated email from the ASF dual-hosted git repository.

mappjzc pushed a commit to branch release-v0.16
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/release-v0.16 by this push:
     new 1262b6c3e fix: cherry pick #5037 (#5049)
1262b6c3e is described below

commit 1262b6c3e42a179db9ac4f7aef251ad20b967485
Author: mappjzc <[email protected]>
AuthorDate: Thu Apr 27 23:50:16 2023 +0800

    fix: cherry pick #5037 (#5049)
    
    * fix: cherry pick #5037
    
    cherry pick #5037
    
    Nddtfjiang <[email protected]>
    
    * fix: fix parent id error
    
    fix parent id error
    
    Nddtfjiang <[email protected]>
---
 backend/plugins/gitlab/api/remote.go | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/backend/plugins/gitlab/api/remote.go 
b/backend/plugins/gitlab/api/remote.go
index 6aa1774e3..904e41cc8 100644
--- a/backend/plugins/gitlab/api/remote.go
+++ b/backend/plugins/gitlab/api/remote.go
@@ -109,6 +109,12 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
 
        // get gid and pageData
        gid := groupId[0]
+       rgid := gid
+       if len(rgid) >= 6 {
+               if rgid[:6] == "group:" {
+                       rgid = rgid[6:]
+               }
+       }
        pageData, err := GetPageDataFromPageToken(pageToken[0])
        if err != nil {
                return nil, errors.BadInput.New("failed to get paget token")
@@ -134,7 +140,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                        query.Set("top_level_only", "true")
                        res, err = apiClient.Get("groups", query, nil)
                } else {
-                       res, err = 
apiClient.Get(fmt.Sprintf("groups/%s/subgroups", gid), query, nil)
+                       res, err = 
apiClient.Get(fmt.Sprintf("groups/%s/subgroups", rgid), query, nil)
                }
                if err != nil {
                        return nil, err
@@ -150,7 +156,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                for _, group := range resBody {
                        child := RemoteScopesChild{
                                Type: TypeGroup,
-                               Id:   strconv.Itoa(group.Id),
+                               Id:   "group:" + strconv.Itoa(group.Id),
                                Name: group.Name,
                                // don't need to save group into data
                                Data: nil,
@@ -198,7 +204,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                        res, err = 
apiClient.Get(fmt.Sprintf("users/%d/projects", 
apiClient.GetData(models.GitlabApiClientData_UserId)), query, nil)
                } else {
                        query.Set("with_shared", "false")
-                       res, err = 
apiClient.Get(fmt.Sprintf("/groups/%s/projects", gid), query, nil)
+                       res, err = 
apiClient.Get(fmt.Sprintf("/groups/%s/projects", rgid), query, nil)
                }
                if err != nil {
                        return nil, err

Reply via email to