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

abeizn pushed a commit to branch fix#5640-3
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/fix#5640-3 by this push:
     new 09ac14d69 fix: bitbucket search-remote-scopes
09ac14d69 is described below

commit 09ac14d69d3586cf133d562a82d98f11b3e850c6
Author: abeizn <[email protected]>
AuthorDate: Tue Sep 19 20:00:35 2023 +0800

    fix: bitbucket search-remote-scopes
---
 backend/plugins/bitbucket/api/remote.go | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/backend/plugins/bitbucket/api/remote.go 
b/backend/plugins/bitbucket/api/remote.go
index 9287f44c3..3e898236f 100644
--- a/backend/plugins/bitbucket/api/remote.go
+++ b/backend/plugins/bitbucket/api/remote.go
@@ -130,12 +130,13 @@ func SearchRemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutp
                        query.Set("fields", 
"values.name,values.full_name,values.language,values.description,values.owner.display_name,values.created_on,values.updated_on,values.links.clone,values.links.html,pagelen,page,size")
 
                        //list projects part
-                       gid := ``
-                       if strings.Contains(s, `/`) {
-                               gid = strings.Split(s, `/`)[0]
-                               s = strings.Split(s, `/`)[1]
-                       }
-                       query.Set("q", fmt.Sprintf(`name~"%s"`, s))
+                       // gid := ``
+                       // if strings.Contains(s, `/`) {
+                       //      gid = strings.Split(s, `/`)[0]
+                       //      s = strings.Split(s, `/`)[1]
+                       // }
+                       gid, searchName := GetSearch(s)
+                       query.Set("q", fmt.Sprintf(`name~"%s"`, searchName))
 
                        // list repos part
                        res, err := 
apiClient.Get(fmt.Sprintf("/repositories/%s", gid), query, nil)
@@ -154,6 +155,18 @@ func SearchRemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutp
        )
 }
 
+func GetSearch(s string) (string, string) {
+       gid := ""
+       if strings.Contains(s, "/") {
+               parts := strings.Split(s, "/")
+               if len(parts) >= 2 {
+                       gid = parts[0]
+                       s = strings.Join(parts[1:], "/")
+               }
+       }
+       return gid, s
+}
+
 func initialQuery(queryData *api.RemoteQueryData) url.Values {
        query := url.Values{}
        query.Set("page", fmt.Sprintf("%v", queryData.Page))

Reply via email to