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
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection

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
Calls:

PUT /repos/{owner}/{repo}/branches/{branch}/protection

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
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection

get_required_status_checks() RequiredStatusChecks
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

Return type:

github.RequiredStatusChecks.RequiredStatusChecks

edit_required_status_checks(strict: Opt[bool] = NotSet, contexts: Opt[list[str]] = NotSet, checks: Opt[list[str | tuple[str, int]]] = NotSet) RequiredStatusChecks
Calls:

PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

remove_required_status_checks() None
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

get_required_pull_request_reviews() RequiredPullRequestReviews
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

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
Calls:

PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

remove_required_pull_request_reviews() None
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

get_admin_enforcement() bool
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

set_admin_enforcement() None
Calls:

POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

remove_admin_enforcement() None
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

get_user_push_restrictions() PaginatedList[NamedUser]
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

get_team_push_restrictions() PaginatedList[Team]
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams

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
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions

get_required_signatures() bool
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

add_required_signatures() None
Calls:

POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

remove_required_signatures() None
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

get_allow_deletions() bool
Calls:

GET /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions

set_allow_deletions() None
Calls:

POST /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions

remove_allow_deletions() None
Calls:

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/allow_deletions