Skip to content

Commit e07907f

Browse files
JamieHdmitshur
authored andcommitted
Add MaintainerCanModify field to PullRequest, NewPullRequest structs. (google#590)
Resolves google#589.
1 parent 0ce9beb commit e07907f

File tree

2 files changed

+70
-42
lines changed

2 files changed

+70
-42
lines changed

github/github-accessors.go

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/pulls.go

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,36 @@ type PullRequestsService service
2020

2121
// PullRequest represents a GitHub pull request on a repository.
2222
type PullRequest struct {
23-
ID *int `json:"id,omitempty"`
24-
Number *int `json:"number,omitempty"`
25-
State *string `json:"state,omitempty"`
26-
Title *string `json:"title,omitempty"`
27-
Body *string `json:"body,omitempty"`
28-
CreatedAt *time.Time `json:"created_at,omitempty"`
29-
UpdatedAt *time.Time `json:"updated_at,omitempty"`
30-
ClosedAt *time.Time `json:"closed_at,omitempty"`
31-
MergedAt *time.Time `json:"merged_at,omitempty"`
32-
User *User `json:"user,omitempty"`
33-
Merged *bool `json:"merged,omitempty"`
34-
Mergeable *bool `json:"mergeable,omitempty"`
35-
MergedBy *User `json:"merged_by,omitempty"`
36-
Comments *int `json:"comments,omitempty"`
37-
Commits *int `json:"commits,omitempty"`
38-
Additions *int `json:"additions,omitempty"`
39-
Deletions *int `json:"deletions,omitempty"`
40-
ChangedFiles *int `json:"changed_files,omitempty"`
41-
URL *string `json:"url,omitempty"`
42-
HTMLURL *string `json:"html_url,omitempty"`
43-
IssueURL *string `json:"issue_url,omitempty"`
44-
StatusesURL *string `json:"statuses_url,omitempty"`
45-
DiffURL *string `json:"diff_url,omitempty"`
46-
PatchURL *string `json:"patch_url,omitempty"`
47-
ReviewCommentsURL *string `json:"review_comments_url,omitempty"`
48-
ReviewCommentURL *string `json:"review_comment_url,omitempty"`
49-
Assignee *User `json:"assignee,omitempty"`
50-
Assignees []*User `json:"assignees,omitempty"`
51-
Milestone *Milestone `json:"milestone,omitempty"`
23+
ID *int `json:"id,omitempty"`
24+
Number *int `json:"number,omitempty"`
25+
State *string `json:"state,omitempty"`
26+
Title *string `json:"title,omitempty"`
27+
Body *string `json:"body,omitempty"`
28+
CreatedAt *time.Time `json:"created_at,omitempty"`
29+
UpdatedAt *time.Time `json:"updated_at,omitempty"`
30+
ClosedAt *time.Time `json:"closed_at,omitempty"`
31+
MergedAt *time.Time `json:"merged_at,omitempty"`
32+
User *User `json:"user,omitempty"`
33+
Merged *bool `json:"merged,omitempty"`
34+
Mergeable *bool `json:"mergeable,omitempty"`
35+
MergedBy *User `json:"merged_by,omitempty"`
36+
Comments *int `json:"comments,omitempty"`
37+
Commits *int `json:"commits,omitempty"`
38+
Additions *int `json:"additions,omitempty"`
39+
Deletions *int `json:"deletions,omitempty"`
40+
ChangedFiles *int `json:"changed_files,omitempty"`
41+
URL *string `json:"url,omitempty"`
42+
HTMLURL *string `json:"html_url,omitempty"`
43+
IssueURL *string `json:"issue_url,omitempty"`
44+
StatusesURL *string `json:"statuses_url,omitempty"`
45+
DiffURL *string `json:"diff_url,omitempty"`
46+
PatchURL *string `json:"patch_url,omitempty"`
47+
ReviewCommentsURL *string `json:"review_comments_url,omitempty"`
48+
ReviewCommentURL *string `json:"review_comment_url,omitempty"`
49+
Assignee *User `json:"assignee,omitempty"`
50+
Assignees []*User `json:"assignees,omitempty"`
51+
Milestone *Milestone `json:"milestone,omitempty"`
52+
MaintainerCanModify *bool `json:"maintainer_can_modify,omitempty"`
5253

5354
Head *PullRequestBranch `json:"head,omitempty"`
5455
Base *PullRequestBranch `json:"base,omitempty"`
@@ -164,11 +165,12 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo str
164165

165166
// NewPullRequest represents a new pull request to be created.
166167
type NewPullRequest struct {
167-
Title *string `json:"title,omitempty"`
168-
Head *string `json:"head,omitempty"`
169-
Base *string `json:"base,omitempty"`
170-
Body *string `json:"body,omitempty"`
171-
Issue *int `json:"issue,omitempty"`
168+
Title *string `json:"title,omitempty"`
169+
Head *string `json:"head,omitempty"`
170+
Base *string `json:"base,omitempty"`
171+
Body *string `json:"body,omitempty"`
172+
Issue *int `json:"issue,omitempty"`
173+
MaintainerCanModify *bool `json:"maintainer_can_modify,omitempty"`
172174
}
173175

174176
// Create a new pull request on the specified repository.
@@ -191,16 +193,17 @@ func (s *PullRequestsService) Create(ctx context.Context, owner string, repo str
191193
}
192194

193195
type pullRequestUpdate struct {
194-
Title *string `json:"title,omitempty"`
195-
Body *string `json:"body,omitempty"`
196-
State *string `json:"state,omitempty"`
197-
Base *string `json:"base,omitempty"`
196+
Title *string `json:"title,omitempty"`
197+
Body *string `json:"body,omitempty"`
198+
State *string `json:"state,omitempty"`
199+
Base *string `json:"base,omitempty"`
200+
MaintainerCanModify *bool `json:"maintainer_can_modify,omitempty"`
198201
}
199202

200203
// Edit a pull request.
201204
// pull must not be nil.
202205
//
203-
// The following fields are editable: Title, Body, State, and Base.Ref.
206+
// The following fields are editable: Title, Body, State, Base.Ref and MaintainerCanModify.
204207
// Base.Ref updates the base branch of the pull request.
205208
//
206209
// GitHub API docs: https://developer.github.com/v3/pulls/#update-a-pull-request
@@ -212,9 +215,10 @@ func (s *PullRequestsService) Edit(ctx context.Context, owner string, repo strin
212215
u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number)
213216

214217
update := &pullRequestUpdate{
215-
Title: pull.Title,
216-
Body: pull.Body,
217-
State: pull.State,
218+
Title: pull.Title,
219+
Body: pull.Body,
220+
State: pull.State,
221+
MaintainerCanModify: pull.MaintainerCanModify,
218222
}
219223
if pull.Base != nil {
220224
update.Base = pull.Base.Ref

0 commit comments

Comments
 (0)