Skip to content

Commit 30a0351

Browse files
authored
Add support for getting commits from a PR and getting a PR by a commit hash (#302)
* Add GetCommit to pull requests Signed-off-by: Aria Vesta <avesta@marq.com> * Add GetCommits and rename GetCommit to GetByCommit Signed-off-by: Aria Vesta <avesta@marq.com> --------- Signed-off-by: Aria Vesta <avesta@marq.com> Co-authored-by: Aria Vesta <avesta@marq.com>
1 parent 8002b84 commit 30a0351

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

bitbucket.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ type PullRequestsOptions struct {
315315
Query string `json:"query"`
316316
Sort string `json:"sort"`
317317
Draft bool `json:"draft"`
318+
Commit string `json:"commit"`
318319
ctx context.Context
319320
}
320321

pullrequests.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ func (p *PullRequests) Update(po *PullRequestsOptions) (interface{}, error) {
2727
return p.c.execute("PUT", urlStr, data)
2828
}
2929

30+
func (p *PullRequests) GetByCommit(po *PullRequestsOptions) (interface{}, error) {
31+
urlStr := p.c.GetApiBaseURL() + "/repositories/" + po.Owner + "/" + po.RepoSlug + "/commit/" + po.Commit + "/pullrequests/"
32+
return p.c.executePaginated("GET", urlStr, "", nil)
33+
}
34+
35+
func (p *PullRequests) GetCommits(po *PullRequestsOptions) (interface{}, error) {
36+
urlStr := p.c.GetApiBaseURL() + "/repositories/" + po.Owner + "/" + po.RepoSlug + "/pullrequests/" + po.ID + "/commits/"
37+
return p.c.executePaginated("GET", urlStr, "", nil)
38+
}
39+
3040
func (p *PullRequests) Gets(po *PullRequestsOptions) (interface{}, error) {
3141
urlStr := p.c.GetApiBaseURL() + "/repositories/" + po.Owner + "/" + po.RepoSlug + "/pullrequests/"
3242

0 commit comments

Comments
 (0)