summaryrefslogtreecommitdiff
path: root/docs/gl_objects/branches.rst
blob: 279ca0caf9f1ef62102fb86713fc018ed2aecb89 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
########
Branches
########

References
----------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectBranch`
  + :class:`gitlab.v4.objects.ProjectBranchManager`
  + :attr:`gitlab.v4.objects.Project.branches`

* v3 API:

  + :class:`gitlab.v3.objects.ProjectBranch`
  + :class:`gitlab.v3.objects.ProjectBranchManager`
  + :attr:`gitlab.v3.objects.Project.branches`

* GitLab API: https://docs.gitlab.com/ce/api/branches.html

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 are not authorized to push or merge into protected
   branches. This can be changed by passing ``developers_can_push`` or
   ``developers_can_merge``:

   .. code-block:: python

      branch.protect(developers_can_push=True, developers_can_merge=True)