diff --git a/github/github-accessors.go b/github/github-accessors.go index b470ba80255..2650f7f1f44 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -23574,6 +23574,14 @@ func (r *RepositoryRelease) GetID() int64 { return *r.ID } +// GetImmutable returns the Immutable field if it's non-nil, zero value otherwise. +func (r *RepositoryRelease) GetImmutable() bool { + if r == nil || r.Immutable == nil { + return false + } + return *r.Immutable +} + // GetMakeLatest returns the MakeLatest field if it's non-nil, zero value otherwise. func (r *RepositoryRelease) GetMakeLatest() string { if r == nil || r.MakeLatest == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d61b00e5f69..f09107fd157 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -30445,6 +30445,17 @@ func TestRepositoryRelease_GetID(tt *testing.T) { r.GetID() } +func TestRepositoryRelease_GetImmutable(tt *testing.T) { + tt.Parallel() + var zeroValue bool + r := &RepositoryRelease{Immutable: &zeroValue} + r.GetImmutable() + r = &RepositoryRelease{} + r.GetImmutable() + r = nil + r.GetImmutable() +} + func TestRepositoryRelease_GetMakeLatest(tt *testing.T) { tt.Parallel() var zeroValue string diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index b246f0bc35a..fe696c3f7a0 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -2018,8 +2018,9 @@ func TestRepositoryRelease_String(t *testing.T) { TarballURL: Ptr(""), Author: &User{}, NodeID: Ptr(""), + Immutable: Ptr(false), } - want := `github.RepositoryRelease{TagName:"", TargetCommitish:"", Name:"", Body:"", Draft:false, Prerelease:false, MakeLatest:"", DiscussionCategoryName:"", GenerateReleaseNotes:false, ID:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PublishedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", HTMLURL:"", AssetsURL:"", UploadURL:"", ZipballURL:"", TarballURL:"", Author:github.User{}, NodeID:""}` + want := `github.RepositoryRelease{TagName:"", TargetCommitish:"", Name:"", Body:"", Draft:false, Prerelease:false, MakeLatest:"", DiscussionCategoryName:"", GenerateReleaseNotes:false, ID:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PublishedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", HTMLURL:"", AssetsURL:"", UploadURL:"", ZipballURL:"", TarballURL:"", Author:github.User{}, NodeID:"", Immutable:false}` if got := v.String(); got != want { t.Errorf("RepositoryRelease.String = %v, want %v", got, want) } diff --git a/github/repos_releases.go b/github/repos_releases.go index 87056071c9f..db0f0d9279f 100644 --- a/github/repos_releases.go +++ b/github/repos_releases.go @@ -45,6 +45,7 @@ type RepositoryRelease struct { TarballURL *string `json:"tarball_url,omitempty"` Author *User `json:"author,omitempty"` NodeID *string `json:"node_id,omitempty"` + Immutable *bool `json:"immutable,omitempty"` } func (r RepositoryRelease) String() string { diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 6416086f346..ad147898ee3 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -221,6 +221,7 @@ func TestRepositoriesService_CreateRelease(t *testing.T) { TarballURL: Ptr("http://tarballurl/"), Author: &User{Name: Ptr("octocat")}, NodeID: Ptr("nodeid"), + Immutable: Ptr(false), } mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { @@ -290,6 +291,7 @@ func TestRepositoriesService_EditRelease(t *testing.T) { TarballURL: Ptr("http://tarballurl/"), Author: &User{Name: Ptr("octocat")}, NodeID: Ptr("nodeid"), + Immutable: Ptr(false), } mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -875,6 +877,7 @@ func TestRepositoryRelease_Marshal(t *testing.T) { TarballURL: Ptr("turl"), Author: &User{ID: Ptr(int64(1))}, NodeID: Ptr("nid"), + Immutable: Ptr(true), } want := `{ @@ -903,7 +906,8 @@ func TestRepositoryRelease_Marshal(t *testing.T) { "author": { "id": 1 }, - "node_id": "nid" + "node_id": "nid", + "immutable": true }` testJSONMarshal(t, u, want)