Skip to content

refactor!: Pass release params by value and rename EditRelease to UpdateRelease#4329

Open
JamBalaya56562 wants to merge 1 commit into
google:masterfrom
JamBalaya56562:refactor/3644-release-value-params
Open

refactor!: Pass release params by value and rename EditRelease to UpdateRelease#4329
JamBalaya56562 wants to merge 1 commit into
google:masterfrom
JamBalaya56562:refactor/3644-release-value-params

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

BREAKING CHANGE: CreateRelease & UpdateRelease now take RepositoryRelease by value; EditRelease is renamed to UpdateRelease.

Towards #3644.

Passes the request body of RepositoriesService.CreateRelease and RepositoriesService.UpdateRelease by value instead of by pointer, and renames EditRelease to UpdateRelease for naming consistency.

This continues the value-parameter conversion from the merged #3654, #3794 and #4320, and follows the Edit -> Update rename done for GistsService in #4320.

Changes

Breaking changes

  • CreateRelease / UpdateRelease now take RepositoryRelease by value.
  • EditRelease is renamed to UpdateRelease.

The remaining body-pointer methods in repos_releases.go (EditReleaseAsset, GenerateReleaseNotes) are intentionally left for a follow-up, since they also involve allow-list and type-name changes.

Generated files are unchanged (no struct fields changed).

JamBalaya56562 added a commit to JamBalaya56562/go-github that referenced this pull request Jun 24, 2026
@gmlewis gmlewis added NeedsReview PR is awaiting a review before merging. Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). labels Jun 24, 2026
@gmlewis gmlewis changed the title refactor!: Pass release params by value and rename EditRelease to UpdateRelease refactor!: Pass release params by value and rename EditRelease to UpdateRelease Jun 24, 2026
@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.48%. Comparing base (642da7d) to head (419cb63).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4329      +/-   ##
==========================================
- Coverage   97.48%   97.48%   -0.01%     
==========================================
  Files         193      193              
  Lines       19400    19377      -23     
==========================================
- Hits        18912    18889      -23     
  Misses        270      270              
  Partials      218      218              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @JamBalaya56562!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

cc: @stevehipwell - @alexandear - @Not-Dhananjay-Mishra

@alexandear alexandear left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As we are making breaking changes, I propose creating separate structs for creating and updating a repository release. These structs have slightly different fields.

Comment thread github/repos_releases.go Outdated
return nil, nil, errors.New("release must be provided")
}

func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release RepositoryRelease) (*RepositoryRelease, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, release RepositoryRelease) (*RepositoryRelease, *Response, error) {
func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo string, body CreateReleaseRequest) (*RepositoryRelease, *Response, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 69f00c3 — added a dedicated CreateReleaseRequest and CreateRelease now takes it by value. Thanks!

Comment thread github/repos_releases.go Outdated
return nil, nil, errors.New("release must be provided")
}

func (s *RepositoriesService) UpdateRelease(ctx context.Context, owner, repo string, id int64, release RepositoryRelease) (*RepositoryRelease, *Response, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (s *RepositoriesService) UpdateRelease(ctx context.Context, owner, repo string, id int64, release RepositoryRelease) (*RepositoryRelease, *Response, error) {
func (s *RepositoriesService) UpdateRelease(ctx context.Context, owner, repo string, id int64, body UpdateReleaseRequest) (*RepositoryRelease, *Response, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — UpdateRelease now takes UpdateReleaseRequest by value. It omits GenerateReleaseNotes, since the update endpoint does not accept it.

Comment thread github/repos_releases.go Outdated
Comment on lines 182 to 198

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can remove this after introducing CreateReleaseRequest and UpdateReleaseRequest

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed — the internal repositoryReleaseRequest is gone now that CreateReleaseRequest/UpdateReleaseRequest carry the request fields directly and are serialized as-is.

@JamBalaya56562 JamBalaya56562 force-pushed the refactor/3644-release-value-params branch from 3d68e64 to 69f00c3 Compare June 25, 2026 02:03
…Release

Introduce dedicated CreateReleaseRequest and UpdateReleaseRequest types
for the bodies of RepositoriesService.CreateRelease and
RepositoriesService.UpdateRelease, replacing the *RepositoryRelease
parameter that also carried response-only fields. The new types are
passed by value and serialized directly, dropping the internal
repositoryReleaseRequest remap. EditRelease is renamed to UpdateRelease
for naming consistency.

This follows the value-parameter pattern established by the merged
google#3654, google#3794 and google#4320, the Edit -> Update rename from google#4320, and the
dedicated *Request body convention already used across the package (e.g.
CreateHostedRunnerRequest). The runtime nil checks are removed since a
value parameter makes them unnecessary. No deprecated wrappers are added
(clean break).

Updates google#3644.
@JamBalaya56562 JamBalaya56562 force-pushed the refactor/3644-release-value-params branch from 69f00c3 to 419cb63 Compare June 25, 2026 02:06
Comment on lines +214 to 219
want := &CreateReleaseRequest{
Name: Ptr("v1.0"),
DiscussionCategoryName: Ptr("General"),
GenerateReleaseNotes: Ptr(true),
}
testJSONBody(t, r, want)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
testJSONBody(t, r, input)

Comment on lines +260 to 264
want := &UpdateReleaseRequest{
Name: Ptr("n"),
DiscussionCategoryName: Ptr("General"),
}
testJSONBody(t, r, want)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
testJSONBody(t, r, input)

Comment thread github/repos_releases.go
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`

// The following fields are not used in EditRelease:
// The following fields are not used in UpdateRelease:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is no longer needed:

Suggested change
// The following fields are not used in UpdateRelease:

Comment thread github/repos_releases.go
GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"`

// The following fields are not used in CreateRelease or EditRelease:
// The following fields are not used in CreateRelease or UpdateRelease:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is no longer needed:

Suggested change
// The following fields are not used in CreateRelease or UpdateRelease:

Comment thread github/repos_releases.go
Prerelease *bool `json:"prerelease,omitempty"`
// CreateReleaseRequest represents a request to create a release in a repository.
type CreateReleaseRequest struct {
TagName *string `json:"tag_name,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
TagName *string `json:"tag_name,omitempty"`
TagName string `json:"tag_name"`
Image

client, mux, _ := setup(t)

input := &RepositoryRelease{
input := CreateReleaseRequest{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fill required TagName.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Breaking API Change PR will require a bump to the major version num in next release. Look here to see the change(s). NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants