Skip to content

Commit

Permalink
Remove GenerateReleaseNotes from RepositoriesService.EditRelease
Browse files Browse the repository at this point in the history
According to the [GitHub v3 API reference](https://docs.github.com/en/rest/releases/releases#update-a-release),
`generate_release_notes` is not a recognised body parameter of the endpoint to update a release. If provided to
the API, it will have no effect.

This commit removes the setting of this parameter when updating a release, to avoid confusion in the effect of
setting this parameter.
  • Loading branch information
coro committed Aug 24, 2022
1 parent 243bda8 commit 4bd098b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
5 changes: 3 additions & 2 deletions github/repos_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ type RepositoryRelease struct {
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`
GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"`

// The following fields are not used in EditRelease:
GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"`

// The following fields are not used in CreateRelease or EditRelease:
ID *int64 `json:"id,omitempty"`
Expand Down Expand Up @@ -228,7 +230,6 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin
Draft: release.Draft,
Prerelease: release.Prerelease,
DiscussionCategoryName: release.DiscussionCategoryName,
GenerateReleaseNotes: release.GenerateReleaseNotes,
}

req, err := s.client.NewRequest("PATCH", u, releaseReq)
Expand Down
27 changes: 13 additions & 14 deletions github/repos_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,20 @@ func TestRepositoriesService_EditRelease(t *testing.T) {
input := &RepositoryRelease{
Name: String("n"),
DiscussionCategoryName: String("General"),
GenerateReleaseNotes: Bool(true),
// Fields to be removed:
ID: Int64(2),
CreatedAt: &Timestamp{referenceTime},
PublishedAt: &Timestamp{referenceTime},
URL: String("http://url/"),
HTMLURL: String("http://htmlurl/"),
AssetsURL: String("http://assetsurl/"),
Assets: []*ReleaseAsset{{ID: Int64(5)}},
UploadURL: String("http://uploadurl/"),
ZipballURL: String("http://zipballurl/"),
TarballURL: String("http://tarballurl/"),
Author: &User{Name: String("octocat")},
NodeID: String("nodeid"),
GenerateReleaseNotes: Bool(true),
ID: Int64(2),
CreatedAt: &Timestamp{referenceTime},
PublishedAt: &Timestamp{referenceTime},
URL: String("http://url/"),
HTMLURL: String("http://htmlurl/"),
AssetsURL: String("http://assetsurl/"),
Assets: []*ReleaseAsset{{ID: Int64(5)}},
UploadURL: String("http://uploadurl/"),
ZipballURL: String("http://zipballurl/"),
TarballURL: String("http://tarballurl/"),
Author: &User{Name: String("octocat")},
NodeID: String("nodeid"),
}

mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) {
Expand All @@ -297,7 +297,6 @@ func TestRepositoriesService_EditRelease(t *testing.T) {
want := &repositoryReleaseRequest{
Name: String("n"),
DiscussionCategoryName: String("General"),
GenerateReleaseNotes: Bool(true),
}
if !cmp.Equal(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
Expand Down

0 comments on commit 4bd098b

Please sign in to comment.