summaryrefslogtreecommitdiff
path: root/docs/gl_objects/branches.rst
blob: 50b97a7997219b060f6c258ff3bbca7654561ed3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
########
Branches
########

Use :class:`~gitlab.objects.ProjectBranch` objects to manipulate repository
branches.

To create :class:`~gitlab.objects.ProjectBranch` objects use the
:attr:`gitlab.Gitlab.project_branches` or :attr:`Project.branches
<gitlab.objects.Project.branches>` managers.

Examples
========

Get the list of branches for a repository:

.. literalinclude:: branches.py
   :start-after: # list
   :end-before: # end list

Get a single repository branch:

.. literalinclude:: branches.py
   :start-after: # get
   :end-before: # end get

Create a repository branch:

.. literalinclude:: branches.py
   :start-after: # create
   :end-before: # end create

Delete a repository branch:

.. literalinclude:: branches.py
   :start-after: # delete
   :end-before: # end delete

Protect/unprotect a repository branch:

.. literalinclude:: branches.py
   :start-after: # protect
   :end-before: # end protect
   
.. note::
   
   By default, developers will not be able to push or merge into
   protected branches. This can be changed by passing ``developers_can_push``
   or ``developers_can_merge`` like so: 
   ``branch.protect(developers_can_push=False, developers_can_merge=True)``