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

mintsweet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new 7ac2edb2f fix: config ui do not support same group and project id 
(#5037)
7ac2edb2f is described below

commit 7ac2edb2f3c88a018077c33432ca1366b3611d49
Author: mappjzc <[email protected]>
AuthorDate: Thu Apr 27 09:36:16 2023 +0800

    fix: config ui do not support same group and project id (#5037)
    
    rename group id, add group: before the id.
    
    Nddtfjiang <[email protected]>
---
 backend/plugins/gitlab/api/remote.go     | 12 ++++++++++--
 backend/plugins/gitlab/models/project.go |  7 ++++---
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/backend/plugins/gitlab/api/remote.go 
b/backend/plugins/gitlab/api/remote.go
index 16916ce05..545e8d26f 100644
--- a/backend/plugins/gitlab/api/remote.go
+++ b/backend/plugins/gitlab/api/remote.go
@@ -20,13 +20,14 @@ package api
 import (
        "context"
        "fmt"
+       "net/http"
+       "net/url"
+
        context2 "github.com/apache/incubator-devlake/core/context"
        "github.com/apache/incubator-devlake/core/errors"
        "github.com/apache/incubator-devlake/core/plugin"
        "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "github.com/apache/incubator-devlake/plugins/gitlab/models"
-       "net/http"
-       "net/url"
 )
 
 // RemoteScopes list all available scope for users
@@ -57,6 +58,9 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                                        return nil, err
                                }
                        } else {
+                               if gid[:6] == "group:" {
+                                       gid = gid[6:]
+                               }
                                res, err = 
apiClient.Get(fmt.Sprintf("groups/%s/subgroups", gid), query, nil)
                                if err != nil {
                                        return nil, err
@@ -67,6 +71,7 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                        if err != nil {
                                return nil, err
                        }
+
                        return resBody, err
                },
                func(basicRes context2.BasicRes, gid string, queryData 
*api.RemoteQueryData, connection models.GitlabConnection) 
([]models.GitlabApiProject, errors.Error) {
@@ -83,6 +88,9 @@ func RemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutput, er
                                }
                        } else {
                                query.Set("with_shared", "false")
+                               if gid[:6] == "group:" {
+                                       gid = gid[6:]
+                               }
                                res, err = 
apiClient.Get(fmt.Sprintf("/groups/%s/projects", gid), query, nil)
                                if err != nil {
                                        return nil, err
diff --git a/backend/plugins/gitlab/models/project.go 
b/backend/plugins/gitlab/models/project.go
index 5003d1302..7368a9ab6 100644
--- a/backend/plugins/gitlab/models/project.go
+++ b/backend/plugins/gitlab/models/project.go
@@ -18,11 +18,12 @@ limitations under the License.
 package models
 
 import (
-       "github.com/apache/incubator-devlake/core/plugin"
-       helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
        "strconv"
        "time"
 
+       "github.com/apache/incubator-devlake/core/plugin"
+       helper "github.com/apache/incubator-devlake/helpers/pluginhelper/api"
+
        "github.com/apache/incubator-devlake/core/models/common"
 )
 
@@ -118,7 +119,7 @@ type GroupResponse struct {
 }
 
 func (p GroupResponse) GroupId() string {
-       return strconv.Itoa(p.Id)
+       return "group:" + strconv.Itoa(p.Id)
 }
 
 func (p GroupResponse) GroupName() string {

Reply via email to