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

abeizn 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 11c25bc62 fix: bitbucket search remote scopes not functional (#6312)
11c25bc62 is described below

commit 11c25bc62c984e289ad591645a6326934f664f1a
Author: Klesh Wong <[email protected]>
AuthorDate: Thu Oct 26 10:42:58 2023 +0800

    fix: bitbucket search remote scopes not functional (#6312)
---
 backend/plugins/bitbucket/api/remote.go | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/backend/plugins/bitbucket/api/remote.go 
b/backend/plugins/bitbucket/api/remote.go
index a5dd2d422..820c1ece7 100644
--- a/backend/plugins/bitbucket/api/remote.go
+++ b/backend/plugins/bitbucket/api/remote.go
@@ -126,13 +126,16 @@ func SearchRemoteScopes(input *plugin.ApiResourceInput) 
(*plugin.ApiResourceOutp
                                return nil, errors.BadInput.New("empty search 
query")
                        }
                        s := queryData.Search[0]
+                       if strings.Contains(s, `"`) {
+                               return nil, errors.BadInput.New("search query 
contains invalid character")
+                       }
                        query.Set("sort", "name")
                        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")
-                       gid, searchName := getSearch(s)
-                       query.Set("q", fmt.Sprintf(`name~"%s"`, searchName))
+                       query.Set("role", "member")
+                       query.Set("q", fmt.Sprintf(`full_name~"%s"`, s))
 
                        // list repos part
-                       res, err := 
apiClient.Get(fmt.Sprintf("/repositories/%s", gid), query, nil)
+                       res, err := apiClient.Get("/repositories", query, nil)
                        if err != nil {
                                return nil, err
                        }
@@ -148,18 +151,6 @@ 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