@@ -61,21 +61,32 @@ func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Refer
6161}
6262
6363func (s * gitService ) ListBranches (ctx context.Context , repo string , opts scm.ListOptions ) ([]* scm.Reference , * scm.Response , error ) {
64+ return s .listBranches (ctx , repo , scm.BranchListOptions {
65+ PageListOptions : opts ,
66+ })
67+ }
68+
69+ func (s * gitService ) listBranches (ctx context.Context , repo string , opts scm.BranchListOptions ) ([]* scm.Reference , * scm.Response , error ) {
6470 harnessURI := buildHarnessURI (s .client .account , s .client .organization , s .client .project , repo )
6571 repoID , queryParams , err := getRepoAndQueryParams (harnessURI )
6672 if err != nil {
6773 return nil , nil , err
6874 }
69- path := fmt .Sprintf ("api/v1/repos/%s/branches?%s&%s" , repoID , encodeListOptions (opts ), queryParams )
75+
76+ queryParams = fmt .Sprintf ("%s&include_commit=%t" , queryParams , opts .IncludeCommit )
77+
78+ if opts .SearchTerm != "" {
79+ queryParams = fmt .Sprintf ("%s&query=%s" , queryParams , opts .SearchTerm )
80+ }
81+
82+ path := fmt .Sprintf ("api/v1/repos/%s/branches?%s&%s" , repoID , encodeListOptions (opts .PageListOptions ), queryParams )
7083 out := []* branch {}
7184 res , err := s .client .do (ctx , "GET" , path , nil , & out )
7285 return convertBranchList (out ), res , err
7386}
7487
7588func (s * gitService ) ListBranchesV2 (ctx context.Context , repo string , opts scm.BranchListOptions ) ([]* scm.Reference , * scm.Response , error ) {
76- // Harness doesnt provide support listing based on searchTerm
77- // Hence calling the ListBranches
78- return s .ListBranches (ctx , repo , opts .PageListOptions )
89+ return s .listBranches (ctx , repo , opts )
7990}
8091
8192func (s * gitService ) ListCommits (ctx context.Context , repo string , opts scm.CommitListOptions ) ([]* scm.Commit , * scm.Response , error ) {
0 commit comments