mirror of
https://github.com/status-im/PyGithub.git
synced 2026-08-31 19:01:15 +00:00
A long time ago when branch protection was changed, the example of checking if a branch is protected wasn't changed in the examples. Fixes #1724
52 lines
1.3 KiB
ReStructuredText
52 lines
1.3 KiB
ReStructuredText
Branch
|
|
==========
|
|
|
|
Get list of branches
|
|
--------------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> repo = g.get_repo("PyGithub/PyGithub")
|
|
>>> list(repo.get_branches())
|
|
[Branch(name="master")]
|
|
|
|
Note that the Branch object returned by get_branches() is not fully populated,
|
|
and you can not query everything. Use get_branch(branch="master") once you
|
|
have the branch name.
|
|
|
|
Get a branch
|
|
------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> repo = g.get_repo("PyGithub/PyGithub")
|
|
>>> repo.get_branch(branch="master")
|
|
Branch(name="master")
|
|
|
|
Get HEAD commit of a branch
|
|
---------------------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
|
|
>>> branch.commit
|
|
Commit(sha="5e69ff00a3be0a76b13356c6ff42af79ff469ef3")
|
|
|
|
Get protection status of a branch
|
|
---------------------------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
|
|
>>> branch.protected
|
|
True
|
|
|
|
See required status checks of a branch
|
|
--------------------------------------
|
|
|
|
.. code-block:: python
|
|
|
|
>>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
|
|
>>> branch.get_required_status_checks()
|
|
RequiredStatusChecks(url="https://api.github.com/repos/PyGithub/PyGithub/branches/master/protection/required_status_checks", strict=True)
|