Skip to content

feat: Add repository-level immutable releases settings#4039

Open
sheeeng wants to merge 5 commits intogoogle:masterfrom
sheeeng:feature/repo-immutable-releases
Open

feat: Add repository-level immutable releases settings#4039
sheeeng wants to merge 5 commits intogoogle:masterfrom
sheeeng:feature/repo-immutable-releases

Conversation

@sheeeng
Copy link
Contributor

@sheeeng sheeeng commented Feb 25, 2026

Summary

Add support for the repository-level immutable releases settings API endpoints on RepositoriesService:

  • EnableImmutableReleasesPUT /repos/{owner}/{repo}/immutable-releases
  • DisableImmutableReleasesDELETE /repos/{owner}/{repo}/immutable-releases
  • IsImmutableReleasesEnabledGET /repos/{owner}/{repo}/immutable-releases

This 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

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
Copy link

codecov bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.09%. Comparing base (e3c4fb5) to head (9e97a1e).
⚠️ Report is 22 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Feb 26, 2026
@gmlewis
Copy link
Collaborator

gmlewis commented Feb 26, 2026

Please run step 4 of CONTRIBUTING.md and push the results. Then we can start reviewing.

@sheeeng sheeeng marked this pull request as draft February 27, 2026 12:17
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.
@sheeeng sheeeng marked this pull request as ready for review February 27, 2026 13:25
@sheeeng sheeeng marked this pull request as draft February 27, 2026 13:26
@sheeeng
Copy link
Contributor Author

sheeeng commented Feb 27, 2026

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.
@sheeeng sheeeng changed the title feat: Add repository-level immutable releases settings API feat: add repository-level immutable releases settings Feb 27, 2026
@sheeeng sheeeng marked this pull request as ready for review February 27, 2026 13:30
@gmlewis gmlewis changed the title feat: add repository-level immutable releases settings feat: Add repository-level immutable releases settings Feb 27, 2026
Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Rename `IsImmutableReleasesEnabled` to `AreImmutableReleasesEnabled`
so the method name reads correctly in English.
Use idiomatic Go zero-value pattern `var status *T` instead of
`status := new(T)` in `AreImmutableReleasesEnabled`.
@sheeeng
Copy link
Contributor Author

sheeeng commented Feb 28, 2026

$ CGO_ENABLED=0 script/fmt.sh
Time: 0h:00m:51s
$
$ 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
Time: 0h:03m:17s
$
$ CGO_ENABLED=0 script/test.sh
testing .
ok  	github.com/google/go-github/v82/github	4.718s	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.578s	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
$

@sheeeng sheeeng requested a review from gmlewis February 28, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

NeedsReview PR is awaiting a review before merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for repository-level immutable releases settings API

3 participants