Skip to content

Commit

Permalink
Add FromPullRequest to GetDiffStat (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
CescHolly committed Apr 23, 2024
1 parent 2bd57c5 commit 2fc2e79
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
26 changes: 14 additions & 12 deletions bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 11 additions & 3 deletions diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,30 @@ 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))
}

if dso.Path != "" {
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))
}
Expand Down

0 comments on commit 2fc2e79

Please sign in to comment.