Skip to content

Commit

Permalink
Add MakeLatest parameter to support explicitly setting latest release (
Browse files Browse the repository at this point in the history
…#2594)

Fixes: #2593 .
  • Loading branch information
chrisgrautealium committed Dec 8, 2022
1 parent 153bbc2 commit 44d91eb
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
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.

3 changes: 2 additions & 1 deletion github/github-stringify_test.go

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

17 changes: 11 additions & 6 deletions github/repos_releases.go
Expand Up @@ -19,12 +19,14 @@ 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"`
// MakeLatest can be one of: "true", "false", or "legacy".
MakeLatest *string `json:"make_latest,omitempty"`
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`

// The following fields are not used in EditRelease:
Expand Down Expand Up @@ -176,6 +178,7 @@ type repositoryReleaseRequest struct {
Body *string `json:"body,omitempty"`
Draft *bool `json:"draft,omitempty"`
Prerelease *bool `json:"prerelease,omitempty"`
MakeLatest *string `json:"make_latest,omitempty"`
GenerateReleaseNotes *bool `json:"generate_release_notes,omitempty"`
DiscussionCategoryName *string `json:"discussion_category_name,omitempty"`
}
Expand All @@ -196,6 +199,7 @@ func (s *RepositoriesService) CreateRelease(ctx context.Context, owner, repo str
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
MakeLatest: release.MakeLatest,
DiscussionCategoryName: release.DiscussionCategoryName,
GenerateReleaseNotes: release.GenerateReleaseNotes,
}
Expand Down Expand Up @@ -229,6 +233,7 @@ func (s *RepositoriesService) EditRelease(ctx context.Context, owner, repo strin
Body: release.Body,
Draft: release.Draft,
Prerelease: release.Prerelease,
MakeLatest: release.MakeLatest,
DiscussionCategoryName: release.DiscussionCategoryName,
}

Expand Down
4 changes: 4 additions & 0 deletions github/repos_releases_test.go
Expand Up @@ -708,6 +708,7 @@ func TestRepositoryReleaseRequest_Marshal(t *testing.T) {
Body: String("body"),
Draft: Bool(false),
Prerelease: Bool(false),
MakeLatest: String("legacy"),
DiscussionCategoryName: String("dcn"),
}

Expand All @@ -718,6 +719,7 @@ func TestRepositoryReleaseRequest_Marshal(t *testing.T) {
"body": "body",
"draft": false,
"prerelease": false,
"make_latest": "legacy",
"discussion_category_name": "dcn"
}`

Expand Down Expand Up @@ -774,6 +776,7 @@ func TestRepositoryRelease_Marshal(t *testing.T) {
Body: String("body"),
Draft: Bool(false),
Prerelease: Bool(false),
MakeLatest: String("legacy"),
DiscussionCategoryName: String("dcn"),
ID: Int64(1),
CreatedAt: &Timestamp{referenceTime},
Expand All @@ -796,6 +799,7 @@ func TestRepositoryRelease_Marshal(t *testing.T) {
"body": "body",
"draft": false,
"prerelease": false,
"make_latest": "legacy",
"discussion_category_name": "dcn",
"id": 1,
"created_at": ` + referenceTimeStr + `,
Expand Down

0 comments on commit 44d91eb

Please sign in to comment.