Branch
- class github.Branch.Branch
This class represents Branches.
The reference can be found here https://docs.github.com/en/rest/reference/repos#branches
The OpenAPI schema can be found at
/components/schemas/branch-short
/components/schemas/branch-with-protection
/components/schemas/short-branch
- get_protection() BranchProtection
- edit_protection(strict: Opt[bool] = NotSet, contexts: Opt[list[str]] = NotSet, enforce_admins: Opt[bool] = NotSet, dismissal_users: Opt[list[str]] = NotSet, dismissal_teams: Opt[list[str]] = NotSet, dismissal_apps: Opt[list[str]] = NotSet, dismiss_stale_reviews: Opt[bool] = NotSet, require_code_owner_reviews: Opt[bool] = NotSet, required_approving_review_count: Opt[int] = NotSet, user_push_restrictions: Opt[list[str]] = NotSet, team_push_restrictions: Opt[list[str]] = NotSet, app_push_restrictions: Opt[list[str]] = NotSet, required_linear_history: Opt[bool] = NotSet, allow_force_pushes: Opt[bool] = NotSet, required_conversation_resolution: Opt[bool] = NotSet, lock_branch: Opt[bool] = NotSet, allow_fork_syncing: Opt[bool] = NotSet, users_bypass_pull_request_allowances: Opt[list[str]] = NotSet, teams_bypass_pull_request_allowances: Opt[list[str]] = NotSet, apps_bypass_pull_request_allowances: Opt[list[str]] = NotSet, block_creations: Opt[bool] = NotSet, require_last_push_approval: Opt[bool] = NotSet, allow_deletions: Opt[bool] = NotSet, checks: Opt[list[str | tuple[str, int]]] = NotSet) BranchProtection
-
NOTE: The GitHub API groups strict and contexts together, both must be submitted. Take care to pass both as arguments even if only one is changing. Use edit_required_status_checks() to avoid this.
- remove_protection() None
- get_required_status_checks() RequiredStatusChecks
- edit_required_status_checks(strict: Opt[bool] = NotSet, contexts: Opt[list[str]] = NotSet, checks: Opt[list[str | tuple[str, int]]] = NotSet) RequiredStatusChecks
- remove_required_status_checks() None
- get_required_pull_request_reviews() RequiredPullRequestReviews
- edit_required_pull_request_reviews(dismissal_users: Opt[list[str]] = NotSet, dismissal_teams: Opt[list[str]] = NotSet, dismissal_apps: Opt[list[str]] = NotSet, dismiss_stale_reviews: Opt[bool] = NotSet, require_code_owner_reviews: Opt[bool] = NotSet, required_approving_review_count: Opt[int] = NotSet, require_last_push_approval: Opt[bool] = NotSet) RequiredPullRequestReviews
- remove_required_pull_request_reviews() None
- get_admin_enforcement() bool
- set_admin_enforcement() None
- remove_admin_enforcement() None
- get_user_push_restrictions() PaginatedList[NamedUser]
- get_team_push_restrictions() PaginatedList[Team]
- add_user_push_restrictions(*users: str) None
- Calls:
POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
- Users:
list of strings (user names)
- replace_user_push_restrictions(*users: str) None
- Calls:
PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
- Users:
list of strings (user names)
- remove_user_push_restrictions(*users: str) None
- Calls:
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users
- Users:
list of strings (user names)
- add_team_push_restrictions(*teams: str) None
- Calls:
POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
- Teams:
list of strings (team slugs)
- replace_team_push_restrictions(*teams: str) None
- Calls:
PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
- Teams:
list of strings (team slugs)
- remove_team_push_restrictions(*teams: str) None
- Calls:
DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams
- Teams:
list of strings (team slugs)
- remove_push_restrictions() None
- get_required_signatures() bool
- add_required_signatures() None
- remove_required_signatures() None
- get_allow_deletions() bool
- set_allow_deletions() None
- remove_allow_deletions() None