blob: 8860ff9f4eaca6255079883fd0ce960b6839cc45 (
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
|
########
Branches
########
References
----------
* v4 API:
+ :class:`gitlab.v4.objects.ProjectBranch`
+ :class:`gitlab.v4.objects.ProjectBranchManager`
+ :attr:`gitlab.v4.objects.Project.branches`
* GitLab API: https://docs.gitlab.com/ce/api/branches.html
Examples
--------
Get the list of branches for a repository::
branches = project.branches.list()
Get a single repository branch::
branch = project.branches.get('master')
Create a repository branch::
branch = project.branches.create({'branch': 'feature1',
'ref': 'master'})
Delete a repository branch::
project.branches.delete('feature1')
# or
branch.delete()
Protect/unprotect a repository branch::
branch.protect()
branch.unprotect()
.. 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)
Delete the merged branches for a project::
project.delete_merged_branches()
|