feat: Add repository-level immutable releases settings#4039
feat: Add repository-level immutable releases settings#4039sheeeng wants to merge 3 commits intogoogle:masterfrom
Conversation
Add support for the repository-level immutable releases settings
endpoints on RepositoriesService:
- EnableImmutableReleases: PUT /repos/{owner}/{repo}/immutable-releases
- DisableImmutableReleases: DELETE /repos/{owner}/{repo}/immutable-releases
- IsImmutableReleasesEnabled: GET /repos/{owner}/{repo}/immutable-releases
Fixes google#4038.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4039 +/- ##
==========================================
+ Coverage 94.04% 94.09% +0.05%
==========================================
Files 207 208 +1
Lines 19151 19245 +94
==========================================
+ Hits 18010 18109 +99
+ Misses 939 938 -1
+ Partials 202 198 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Please run step 4 of CONTRIBUTING.md and push the results. Then we can start reviewing. |
Update copyright years from 2025 to 2026 in both source and test files. Shorten API docs URLs for `EnableImmutableReleases` and `DisableImmutableReleases` methods. Change `IsImmutableReleasesEnabled` to return an exported `*RepoImmutableReleasesStatus` struct with `Enabled` and `EnforcedByOwner` fields instead of a plain bool.
$ CGO_ENABLED=0 script/fmt.sh
Time: 0h:00m:37s
$
$ CGO_ENABLED=0 script/lint.sh
linting .
0 issues.
linting example
0 issues.
linting otel
0 issues.
linting scrape
0 issues.
linting tools
0 issues.
linting tools/check-structfield-settings
0 issues.
linting tools/fmtpercentv
0 issues.
linting tools/sliceofpointers
0 issues.
linting tools/structfield
0 issues.
validating generated files
$
$ CGO_ENABLED=0 script/test.sh
testing .
ok github.com/google/go-github/v82/github 4.854s coverage: 99.2% of statements
github.com/google/go-github/v82/test/fields coverage: 0.0% of statements
? github.com/google/go-github/v82/test/integration [no test files]
testing example
github.com/google/go-github/v82/example/actionpermissions coverage: 0.0% of statements
github.com/google/go-github/v82/example/appengine coverage: 0.0% of statements
github.com/google/go-github/v82/example/basicauth coverage: 0.0% of statements
github.com/google/go-github/v82/example/codespaces/newreposecretwithxcrypto coverage: 0.0% of statements
github.com/google/go-github/v82/example/codespaces/newusersecretwithxcrypto coverage: 0.0% of statements
github.com/google/go-github/v82/example/commitpr coverage: 0.0% of statements
github.com/google/go-github/v82/example/listenvironments coverage: 0.0% of statements
github.com/google/go-github/v82/example/migrations coverage: 0.0% of statements
github.com/google/go-github/v82/example/newfilewithappauth coverage: 0.0% of statements
github.com/google/go-github/v82/example/newrepo coverage: 0.0% of statements
github.com/google/go-github/v82/example/newreposecretwithxcrypto coverage: 0.0% of statements
github.com/google/go-github/v82/example/otel coverage: 0.0% of statements
github.com/google/go-github/v82/example/ratelimit coverage: 0.0% of statements
github.com/google/go-github/v82/example/simple coverage: 0.0% of statements
github.com/google/go-github/v82/example/tokenauth coverage: 0.0% of statements
github.com/google/go-github/v82/example/topics coverage: 0.0% of statements
github.com/google/go-github/v82/example/uploadreleaseassetfromrelease coverage: 0.0% of statements
github.com/google/go-github/v82/example/verifyartifact coverage: 0.0% of statements
testing otel
ok github.com/google/go-github/v82/otel (cached) coverage: 100.0% of statements
testing scrape
ok github.com/google/go-github/scrape (cached) coverage: 59.4% of statements
github.com/google/go-github/scrape/example/scrape coverage: 0.0% of statements
testing tools
tools/gen-release-notes coverage: 0.0% of statements
ok tools/metadata 1.561s coverage: 81.5% of statements
testing tools/check-structfield-settings
github.com/google/go-github/v82/tools/check-structfield-settings coverage: 0.0% of statements
testing tools/fmtpercentv
ok tools/fmtpercentv (cached) coverage: 81.2% of statements
testing tools/sliceofpointers
ok tools/sliceofpointers (cached) coverage: 94.7% of statements
testing tools/structfield
ok github.com/google/go-github/v82/tools/structfield (cached) coverage: 93.6% of statements
Time: 0h:01m:15s |
|
Appreciate the review, @alexandear! |
Add GetEnabled and GetEnforcedByOwner accessor methods for the `RepoImmutableReleasesStatus` struct with nil-safe checks. Include corresponding unit tests for both accessors.
gmlewis
left a comment
There was a problem hiding this comment.
Thank you, @sheeeng!
Just a couple minor changes, please, then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.
cc: @alexandear since you already commented.
| return resp, nil | ||
| } | ||
|
|
||
| // IsImmutableReleasesEnabled checks if immutable releases are enabled for |
There was a problem hiding this comment.
Can we please rename this method so that it reads better in English?
| // IsImmutableReleasesEnabled checks if immutable releases are enabled for | |
| // AreImmutableReleasesEnabled checks if immutable releases are enabled for |
| status := new(RepoImmutableReleasesStatus) | ||
| resp, err := s.client.Do(ctx, req, status) |
There was a problem hiding this comment.
Can we please use this more idiomatic Go pattern?
I really dislike the use of new when it can easily be avoided by taking advantage of the zero-value.
| status := new(RepoImmutableReleasesStatus) | |
| resp, err := s.client.Do(ctx, req, status) | |
| var status *RepoImmutableReleasesStatus | |
| resp, err := s.client.Do(ctx, req, &status) |
Summary
Add support for the repository-level immutable releases settings API endpoints on
RepositoriesService:EnableImmutableReleases—PUT /repos/{owner}/{repo}/immutable-releasesDisableImmutableReleases—DELETE /repos/{owner}/{repo}/immutable-releasesIsImmutableReleasesEnabled—GET /repos/{owner}/{repo}/immutable-releasesThis follows the same pattern as the private vulnerability reporting methods (
EnablePrivateReporting,DisablePrivateReporting,IsPrivateReportingEnabled) and complements the organization-level immutable releases support added in #3774.Fixes #4038.
GitHub API docs