From 2fc2e797268538354334d727d7418fa628e95504 Mon Sep 17 00:00:00 2001 From: Francesc Holly <47240267+CescHolly@users.noreply.github.com> Date: Tue, 23 Apr 2024 02:28:39 +0200 Subject: [PATCH] Add FromPullRequest to GetDiffStat (#282) --- bitbucket.go | 26 ++++++++++++++------------ diff.go | 14 +++++++++++--- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/bitbucket.go b/bitbucket.go index 4a9c5a0..636ad16 100644 --- a/bitbucket.go +++ b/bitbucket.go @@ -249,7 +249,7 @@ type RepositoryBranchDeleteOptions struct { RepoSlug string `json:"repo_slug"` RepoUUID string `json:"uuid"` RefName string `json:"name"` - RefUUID string `json:uuid` + RefUUID string `json:"uuid"` } type RepositoryBranchTarget struct { @@ -382,17 +382,19 @@ type DiffOptions struct { } type DiffStatOptions struct { - Owner string `json:"owner"` - RepoSlug string `json:"repo_slug"` - Spec string `json:"spec"` - Whitespace bool `json:"ignore_whitespace"` - Merge bool `json:"merge"` - Path string `json:"path"` - Renames bool `json:"renames"` - PageNum int `json:"page"` - Pagelen int `json:"pagelen"` - MaxDepth int `json:"max_depth"` - Fields []string + Owner string `json:"owner"` + RepoSlug string `json:"repo_slug"` + Spec string `json:"spec"` + FromPullRequestID int `json:"from_pullrequest_id"` + Whitespace bool `json:"ignore_whitespace"` + Merge bool `json:"merge"` + Path string `json:"path"` + Renames bool `json:"renames"` + Topic bool `json:"topic"` + PageNum int `json:"page"` + Pagelen int `json:"pagelen"` + MaxDepth int `json:"max_depth"` + Fields []string } type WebhooksOptions struct { diff --git a/diff.go b/diff.go index b793db3..4117714 100644 --- a/diff.go +++ b/diff.go @@ -44,11 +44,15 @@ func (d *Diff) GetPatch(do *DiffOptions) (interface{}, error) { func (d *Diff) GetDiffStat(dso *DiffStatOptions) (*DiffStatRes, error) { params := url.Values{} - if dso.Whitespace == true { + if dso.FromPullRequestID > 0 { + params.Add("from_pullrequest_id", strconv.Itoa(dso.FromPullRequestID)) + } + + if dso.Whitespace { params.Add("ignore_whitespace", strconv.FormatBool(dso.Whitespace)) } - if dso.Merge == false { + if !dso.Merge { params.Add("merge", strconv.FormatBool(dso.Merge)) } @@ -56,10 +60,14 @@ func (d *Diff) GetDiffStat(dso *DiffStatOptions) (*DiffStatRes, error) { params.Add("path", dso.Path) } - if dso.Renames == false { + if !dso.Renames { params.Add("renames", strconv.FormatBool(dso.Renames)) } + if dso.Topic { + params.Add("topic", strconv.FormatBool(dso.Topic)) + } + if dso.PageNum > 0 { params.Add("page", strconv.Itoa(dso.PageNum)) }