Skip to content

Commit c0e2323

Browse files
refactor!: Pass RepositoryMergeRequest and RepoMergeUpstreamRequest by value (#4372)
BREAKING CHANGE: `RepositoriesService.Merge` and `RepositoriesService.MergeUpstream` now pass `body` by value and required struct fields are now values.
1 parent e77be1b commit c0e2323

5 files changed

Lines changed: 22 additions & 33 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,11 @@ linters:
252252
- PullRequestReviewDismissalRequest
253253
- PullRequestReviewRequest
254254
- PullRequestReviewsEnforcementUpdate
255-
- RepoMergeUpstreamRequest
256255
- Repository
257256
- RepositoryAddCollaboratorOptions
258257
- RepositoryComment
259258
- RepositoryContentFileOptions
260259
- RepositoryCreateForkOptions
261-
- RepositoryMergeRequest
262260
- RequiredStatusChecksRequest
263261
- ReviewCustomDeploymentProtectionRuleRequest
264262
- SCIMUserAttributes

github/github-accessors.go

Lines changed: 9 additions & 9 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: 3 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/repos_merging.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313
// RepositoryMergeRequest represents a request to merge a branch in a
1414
// repository.
1515
type RepositoryMergeRequest struct {
16-
Base *string `json:"base,omitempty"`
17-
Head *string `json:"head,omitempty"`
16+
Base string `json:"base"`
17+
Head string `json:"head"`
1818
CommitMessage *string `json:"commit_message,omitempty"`
1919
}
2020

2121
// RepoMergeUpstreamRequest represents a request to sync a branch of
2222
// a forked repository to keep it up-to-date with the upstream repository.
2323
type RepoMergeUpstreamRequest struct {
24-
Branch *string `json:"branch,omitempty"`
24+
Branch string `json:"branch"`
2525
}
2626

2727
// RepoMergeUpstreamResult represents the result of syncing a branch of
@@ -37,7 +37,7 @@ type RepoMergeUpstreamResult struct {
3737
// GitHub API docs: https://docs.github.com/rest/branches/branches?apiVersion=2022-11-28#merge-a-branch
3838
//
3939
//meta:operation POST /repos/{owner}/{repo}/merges
40-
func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, body *RepositoryMergeRequest) (*RepositoryCommit, *Response, error) {
40+
func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, body RepositoryMergeRequest) (*RepositoryCommit, *Response, error) {
4141
u := fmt.Sprintf("repos/%v/%v/merges", owner, repo)
4242
req, err := s.client.NewRequest(ctx, "POST", u, body)
4343
if err != nil {
@@ -59,7 +59,7 @@ func (s *RepositoriesService) Merge(ctx context.Context, owner, repo string, bod
5959
// GitHub API docs: https://docs.github.com/rest/branches/branches?apiVersion=2022-11-28#sync-a-fork-branch-with-the-upstream-repository
6060
//
6161
//meta:operation POST /repos/{owner}/{repo}/merge-upstream
62-
func (s *RepositoriesService) MergeUpstream(ctx context.Context, owner, repo string, body *RepoMergeUpstreamRequest) (*RepoMergeUpstreamResult, *Response, error) {
62+
func (s *RepositoriesService) MergeUpstream(ctx context.Context, owner, repo string, body RepoMergeUpstreamRequest) (*RepoMergeUpstreamResult, *Response, error) {
6363
u := fmt.Sprintf("repos/%v/%v/merge-upstream", owner, repo)
6464
req, err := s.client.NewRequest(ctx, "POST", u, body)
6565
if err != nil {

github/repos_merging_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ func TestRepositoriesService_Merge(t *testing.T) {
1717
t.Parallel()
1818
client, mux, _ := setup(t)
1919

20-
input := &RepositoryMergeRequest{
21-
Base: Ptr("b"),
22-
Head: Ptr("h"),
20+
input := RepositoryMergeRequest{
21+
Base: "b",
22+
Head: "h",
2323
CommitMessage: Ptr("c"),
2424
}
2525

@@ -59,8 +59,8 @@ func TestRepositoriesService_MergeUpstream(t *testing.T) {
5959
t.Parallel()
6060
client, mux, _ := setup(t)
6161

62-
input := &RepoMergeUpstreamRequest{
63-
Branch: Ptr("b"),
62+
input := RepoMergeUpstreamRequest{
63+
Branch: "b",
6464
}
6565

6666
mux.HandleFunc("/repos/o/r/merge-upstream", func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)