Skip to content

Add Draft Pull request option #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bitbucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ type PullRequestsOptions struct {
States []string `json:"states"`
Query string `json:"query"`
Sort string `json:"sort"`
Draft bool `json:"draft"`
ctx context.Context
}

Expand Down Expand Up @@ -665,8 +666,8 @@ func (dk *DeployKeyOptions) WithContext(ctx context.Context) *DeployKeyOptions {
}

type SSHKeyOptions struct {
Owner string `json:"owner"`
Uuid string `json:"uuid"`
Label string `json:"label"`
Key string `json:"key"`
Owner string `json:"owner"`
Uuid string `json:"uuid"`
Label string `json:"label"`
Key string `json:"key"`
}
6 changes: 5 additions & 1 deletion pullrequests.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,14 @@ func (p *PullRequests) buildPullRequestBody(po *PullRequestsOptions) (string, er
body["message"] = po.Message
}

if po.CloseSourceBranch == true || po.CloseSourceBranch == false {
if po.CloseSourceBranch || !po.CloseSourceBranch {
body["close_source_branch"] = po.CloseSourceBranch
Comment on lines +245 to 246

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This condition is always true and can be simplified to true. Consider removing the condition altogether and directly assigning body["close_source_branch"] = po.CloseSourceBranch.

Alternatively, you can simplify the condition to po.CloseSourceBranch || !po.CloseSourceBranch which is also always true, but less readable than just true.

body["close_source_branch"] = po.CloseSourceBranch

}

if po.Draft {
body["draft"] = true
}

data, err := json.Marshal(body)
if err != nil {
return "", err
Expand Down