@@ -61,21 +61,32 @@ func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Refer
61
61
}
62
62
63
63
func (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 ) {
64
70
harnessURI := buildHarnessURI (s .client .account , s .client .organization , s .client .project , repo )
65
71
repoID , queryParams , err := getRepoAndQueryParams (harnessURI )
66
72
if err != nil {
67
73
return nil , nil , err
68
74
}
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 )
70
83
out := []* branch {}
71
84
res , err := s .client .do (ctx , "GET" , path , nil , & out )
72
85
return convertBranchList (out ), res , err
73
86
}
74
87
75
88
func (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 )
79
90
}
80
91
81
92
func (s * gitService ) ListCommits (ctx context.Context , repo string , opts scm.CommitListOptions ) ([]* scm.Commit , * scm.Response , error ) {
0 commit comments