Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 19 additions & 18 deletions github/github-stringify_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 28 additions & 24 deletions github/repos_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import (

// RepositoryRelease represents a GitHub release in a repository.
type RepositoryRelease struct {
TagName *string `json:"tag_name,omitempty"`
TargetCommitish *string `json:"target_commitish,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
TagName *string `json:"tag_name,omitempty"`
TargetCommitish *string `json:"target_commitish,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`

// The following fields are not used in CreateRelease or EditRelease:
ID *int64 `json:"id,omitempty"`
Expand Down Expand Up @@ -134,12 +135,13 @@ func (s *RepositoriesService) getSingleRelease(ctx context.Context, url string)
// See https://github.com/google/go-github/issues/992 for more
// information.
type repositoryReleaseRequest struct {
TagName *string `json:"tag_name,omitempty"`
TargetCommitish *string `json:"target_commitish,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
TagName *string `json:"tag_name,omitempty"`
TargetCommitish *string `json:"target_commitish,omitempty"`
Name *string `json:"name,omitempty"`
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`
}

// CreateRelease adds a new release for a repository.
Expand All @@ -152,12 +154,13 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str
u := fmt.Sprintf("repos/%s/%s/releases", owner, repo)

releaseReq := &repositoryReleaseRequest{
TagName: release.TagName,
TargetCommitish: release.TargetCommitish,
Name: release.Name,
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
TagName: release.TagName,
TargetCommitish: release.TargetCommitish,
Name: release.Name,
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
DiscussionCategoryName: release.DiscussionCategoryName,
}

req, err := s.client.NewRequest("POST", u, releaseReq)
Expand All @@ -183,12 +186,13 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin
u := fmt.Sprintf("repos/%s/%s/releases/%d", owner, repo, id)

releaseReq := &repositoryReleaseRequest{
TagName: release.TagName,
TargetCommitish: release.TargetCommitish,
Name: release.Name,
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
TagName: release.TagName,
TargetCommitish: release.TargetCommitish,
Name: release.Name,
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
DiscussionCategoryName: release.DiscussionCategoryName,
}

req, err := s.client.NewRequest("PATCH", u, releaseReq)
Expand Down
16 changes: 12 additions & 4 deletions github/repos_releases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ func TestRepositoriesService_CreateRelease(t *testing.T) {
defer teardown()

input := &RepositoryRelease{
Name: String("v1.0"),
Name: String("v1.0"),
DiscussionCategoryName: String("General"),
// Fields to be removed:
ID: Int64(2),
CreatedAt: &Timestamp{referenceTime},
Expand All @@ -185,7 +186,10 @@ func TestRepositoriesService_CreateRelease(t *testing.T) {
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "POST")
want := &repositoryReleaseRequest{Name: String("v1.0")}
want := &repositoryReleaseRequest{
Name: String("v1.0"),
DiscussionCategoryName: String("General"),
}
if !reflect.DeepEqual(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
}
Expand Down Expand Up @@ -223,7 +227,8 @@ func TestRepositoriesService_EditRelease(t *testing.T) {
defer teardown()

input := &RepositoryRelease{
Name: String("n"),
Name: String("n"),
DiscussionCategoryName: String("General"),
// Fields to be removed:
ID: Int64(2),
CreatedAt: &Timestamp{referenceTime},
Expand All @@ -244,7 +249,10 @@ func TestRepositoriesService_EditRelease(t *testing.T) {
json.NewDecoder(r.Body).Decode(v)

testMethod(t, r, "PATCH")
want := &repositoryReleaseRequest{Name: String("n")}
want := &repositoryReleaseRequest{
Name: String("n"),
DiscussionCategoryName: String("General"),
}
if !reflect.DeepEqual(v, want) {
t.Errorf("Request body = %+v, want %+v", v, want)
}
Expand Down