@@ -53,19 +53,38 @@ func (s *repositoryService) FindPerms(ctx context.Context, repo string) (*scm.Pe
53
53
}
54
54
55
55
func (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 ) {
56
62
queryParams := fmt .Sprintf ("%s=%s&%s=%s&%s=%s&%s=%s" ,
57
63
projectIdentifier , s .client .project , orgIdentifier , s .client .organization , accountIdentifier , s .client .account ,
58
64
routingId , s .client .account )
59
65
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 )
61
81
out := []* repository {}
62
82
res , err := s .client .do (ctx , "GET" , path , nil , & out )
63
83
return convertRepositoryList (out ), res , err
64
84
}
65
85
66
86
func (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 )
69
88
}
70
89
71
90
func (s * repositoryService ) ListNamespace (ctx context.Context , _ string , opts scm.ListOptions ) ([]* scm.Repository , * scm.Response , error ) {
0 commit comments