/ doc / examples / Branch.rst
Branch.rst
 1  Branch
 2  ==========
 3  
 4  Get list of branches
 5  --------------------
 6  
 7  .. code-block:: python
 8  
 9      >>> repo = g.get_repo("PyGithub/PyGithub")
10      >>> list(repo.get_branches())
11      [Branch(name="master")]
12  
13  Note that the Branch object returned by get_branches() is not fully populated,
14  and you can not query everything. Use get_branch(branch="master") once you
15  have the branch name.
16  
17  Get a branch
18  ------------
19  
20  .. code-block:: python
21  
22      >>> repo = g.get_repo("PyGithub/PyGithub")
23      >>> repo.get_branch(branch="master")
24      Branch(name="master")
25  
26  Get HEAD commit of a branch
27  ---------------------------
28  
29  .. code-block:: python
30  
31      >>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
32      >>> branch.commit
33      Commit(sha="5e69ff00a3be0a76b13356c6ff42af79ff469ef3")
34  
35  Get protection status of a branch
36  ---------------------------------
37  
38  .. code-block:: python
39  
40      >>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
41      >>> branch.protected
42      True
43  
44  See required status checks of a branch
45  --------------------------------------
46  
47  .. code-block:: python
48  
49      >>> branch = g.get_repo("PyGithub/PyGithub").get_branch("master")
50      >>> branch.get_required_status_checks()
51      RequiredStatusChecks(url="https://api.github.com/repos/PyGithub/PyGithub/branches/master/protection/required_status_checks", strict=True)