Skip to content

Add Protection to Branch struct - #3095

Merged
gmlewis merged 1 commit into
google:masterfrom
jscaltreto:branch-protection-in-branch
Mar 11, 2024
Merged

Add Protection to Branch struct#3095
gmlewis merged 1 commit into
google:masterfrom
jscaltreto:branch-protection-in-branch

Conversation

@jscaltreto

Copy link
Copy Markdown
Contributor

Details regarding branch protection are provided APIs which return the "Branch With Protection" schema, such as
'Get a branch'. This allows for getting branch protection information without needing to explicitly call the "Get branch protection" API. As the latter requires administration:read permissions while the former only requires contents:read, this enables users view branch protection information without requiring elevated permissions.

The 'List branches' API returns the Short Branch schema, which does not include protection, but since protected will still be true, a user could subsequently call 'Get a branch' to get further details.

Details regarding branch protection are provided APIs which return the
"Branch With Protection" schema, such as
'[Get a branch](https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#get-a-branch)'.
This allows for getting branch protection information without needing to
explicitly call the "Get branch protection" API. As the latter requires
`administration:read` permissions while the former only requires `contents:read`,
this enables users view branch protection information without requiring
elevated permissions.
The '[List branches](https://docs.github.com/en/rest/branches/branches?apiVersion=2022-11-28#list-branches)'
API returns the `Short Branch` schema, which does not include `protection`,
but since `protected` will still be `true`, a user could subsequently call
'Get a branch' to get further details.
@codecov

codecovBot commented Mar 11, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.87%. Comparing base (2b8c7fa) to head (e374ac8).
Report is 19 commits behind head on master.

Additional details and impacted files
@@ Coverage Diff @@## master #3095 +/- ##
==========================================
- Coverage 97.72% 92.87% -4.86% 
==========================================
Files 153 170 +17 Lines 13390 11403 -1987 ==========================================
- Hits 13085 10590 -2495 - Misses 215 723 +508 
Partials 90 90 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmlewisgmlewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you, @jscaltreto !
LGTM.
Merging.

@gmlewis
gmlewis merged commit 2c1b36c into google:masterMar 11, 2024
jlaportebot added a commit to jlaportebot/go-github that referenced this pull request Jun 28, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jscaltreto@gmlewis