@@ -53,19 +53,38 @@ func (s *repositoryService) FindPerms(ctx context.Context, repo string) (*scm.Pe
5353}
5454
5555func (s * repositoryService ) List (ctx context.Context , opts scm.ListOptions ) ([]* scm.Repository , * scm.Response , error ) {
56+ return s .list (ctx , scm.RepoListOptions {
57+ ListOptions : opts ,
58+ })
59+ }
60+
61+ func (s * repositoryService ) list (ctx context.Context , opts scm.RepoListOptions ) ([]* scm.Repository , * scm.Response , error ) {
5662 queryParams := fmt .Sprintf ("%s=%s&%s=%s&%s=%s&%s=%s" ,
5763 projectIdentifier , s .client .project , orgIdentifier , s .client .organization , accountIdentifier , s .client .account ,
5864 routingId , s .client .account )
5965
60- path := fmt .Sprintf ("api/v1/repos?sort=path&order=asc&%s&%s" , encodeListOptions (opts ), queryParams )
66+ if opts .RepoSearchTerm .RepoName != "" {
67+ queryParams = fmt .Sprintf ("%s&query=%s" , queryParams , opts .RepoSearchTerm .RepoName )
68+ }
69+
70+ sortKey := defaultSortKey
71+ if opts .ListOptions .SortKey != "" {
72+ sortKey = opts .ListOptions .SortKey
73+ }
74+
75+ order := defaultOrder
76+ if opts .ListOptions .Order != "" {
77+ order = opts .ListOptions .Order
78+ }
79+
80+ path := fmt .Sprintf ("api/v1/repos?sort=%s&order=%s&%s&%s" , sortKey , order , encodeListOptions (opts .ListOptions ), queryParams )
6181 out := []* repository {}
6282 res , err := s .client .do (ctx , "GET" , path , nil , & out )
6383 return convertRepositoryList (out ), res , err
6484}
6585
6686func (s * repositoryService ) ListV2 (ctx context.Context , opts scm.RepoListOptions ) ([]* scm.Repository , * scm.Response , error ) {
67- // harness does not support search filters, hence calling List api without search filtering
68- return s .List (ctx , opts .ListOptions )
87+ return s .list (ctx , opts )
6988}
7089
7190func (s * repositoryService ) ListNamespace (ctx context.Context , _ string , opts scm.ListOptions ) ([]* scm.Repository , * scm.Response , error ) {
0 commit comments