Skip to content

Commit f15206a

Browse files
refactor!: Rename NewPullRequest to CreatePullRequest and pass it by value (#4395)
BREAKING CHANGE: `NewPullRequest` is renamed to `CreatePullRequest`, `PullRequests.Create` now takes it by value, and `CreatePullRequest.Head` and `CreatePullRequest.Base` are now `string`.
1 parent ed10621 commit f15206a

7 files changed

Lines changed: 159 additions & 166 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ linters:
238238
- LockIssueOptions
239239
- MaintenanceOptions
240240
- Milestone
241-
- NewPullRequest
242241
- Organization
243242
- PagesUpdate
244243
- PagesUpdateWithoutCNAME

example/commitpr/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ func createPR() (err error) {
194194
prRepo = sourceRepo
195195
}
196196

197-
newPR := &github.NewPullRequest{
197+
newPR := github.CreatePullRequest{
198198
Title: prSubject,
199-
Head: commitBranch,
199+
Head: *commitBranch,
200200
HeadRepo: repoBranch,
201-
Base: prBranch,
201+
Base: *prBranch,
202202
Body: prDescription,
203203
MaintainerCanModify: github.Ptr(true),
204204
}

github/examples_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,10 @@ func ExamplePullRequestsService_Create() {
135135
log.Fatalf("Error creating GitHub client: %v", err)
136136
}
137137

138-
newPR := &github.NewPullRequest{
138+
newPR := github.CreatePullRequest{
139139
Title: github.Ptr("My awesome pull request"),
140-
Head: github.Ptr("branch_to_merge"),
141-
Base: github.Ptr("master"),
140+
Head: "branch_to_merge",
141+
Base: "master",
142142
Body: github.Ptr("This is the description of the PR created with the package `github.com/google/go-github/github`"),
143143
MaintainerCanModify: github.Ptr(true),
144144
}

github/github-accessors.go

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

github/github-accessors_test.go

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

github/pulls.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,19 +258,19 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner, repo string, nu
258258
return buf.String(), resp, nil
259259
}
260260

261-
// NewPullRequest represents a new pull request to be created.
262-
type NewPullRequest struct {
261+
// CreatePullRequest represents a request to create a pull request.
262+
type CreatePullRequest struct {
263263
Title *string `json:"title,omitempty"`
264264
// The name of the branch where your changes are implemented. For
265265
// cross-repository pull requests in the same network, namespace head with
266266
// a user like this: username:branch.
267-
Head *string `json:"head,omitempty"`
267+
Head string `json:"head"`
268268
HeadRepo *string `json:"head_repo,omitempty"`
269269
// The name of the branch you want the changes pulled into. This should be
270270
// an existing branch on the current repository. You cannot submit a pull
271271
// request to one repository that requests a merge to a base of another
272272
// repository.
273-
Base *string `json:"base,omitempty"`
273+
Base string `json:"base"`
274274
Body *string `json:"body,omitempty"`
275275
Issue *int `json:"issue,omitempty"`
276276
MaintainerCanModify *bool `json:"maintainer_can_modify,omitempty"`
@@ -282,7 +282,7 @@ type NewPullRequest struct {
282282
// GitHub API docs: https://docs.github.com/rest/pulls/pulls?apiVersion=2022-11-28#create-a-pull-request
283283
//
284284
//meta:operation POST /repos/{owner}/{repo}/pulls
285-
func (s *PullRequestsService) Create(ctx context.Context, owner, repo string, body *NewPullRequest) (*PullRequest, *Response, error) {
285+
func (s *PullRequestsService) Create(ctx context.Context, owner, repo string, body CreatePullRequest) (*PullRequest, *Response, error) {
286286
u := fmt.Sprintf("repos/%v/%v/pulls", owner, repo)
287287
req, err := s.client.NewRequest(ctx, "POST", u, body)
288288
if err != nil {

0 commit comments

Comments
 (0)