Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcdd801e

Browse files
author
Gauvain Pocentek
committed
Add branches API documentation
1 parentc88c638 commitcdd801e

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

‎docs/api-objects.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
########################
2+
API objects manipulation
3+
########################
4+
5+
..toctree::
6+
7+
gl_objects/branches

‎docs/gl_objects/branches.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# list
2+
branches=gl.project_branches.list(project_id=1)
3+
# or
4+
branches=project.branches.list()
5+
# end list
6+
7+
# get
8+
branch=gl.project_branches.get(project_id=1,id='master')
9+
# or
10+
branch=project.branches.get('master')
11+
# end get
12+
13+
# create
14+
branch=gl.project_branches.create({'branch_name':'feature1',
15+
'ref':'master'},
16+
project_id=1)
17+
# or
18+
branch=project.branches.create({'branch_name':'feature1',
19+
'ref':'master'})
20+
# end create
21+
22+
# delete
23+
gl.project_branches.delete(project_id=1,id='feature1')
24+
# or
25+
project.branches.delete('feature1')
26+
# or
27+
branch.delete()
28+
# end delete
29+
30+
# protect
31+
branch.protect()
32+
branch.unprotect()
33+
# end protect

‎docs/gl_objects/branches.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
########
2+
Branches
3+
########
4+
5+
Use:class:`ProjectBranch` objects to manipulate repository branches.
6+
7+
To create:class:`ProjectBranch` objects use the
8+
:class:`Gitlab.project_branches` or:class:`Project.branches` managers.
9+
10+
Examples
11+
========
12+
13+
Get the list of branches for a repository:
14+
15+
..literalinclude::branches.py
16+
:start-after: # list
17+
:end-before: # end list
18+
19+
Get a single repository branch:
20+
21+
..literalinclude::branches.py
22+
:start-after: # get
23+
:end-before: # end get
24+
25+
Create a repository branch:
26+
27+
..literalinclude::branches.py
28+
:start-after: # create
29+
:end-before: # end create
30+
31+
Delete a repository branch:
32+
33+
..literalinclude::branches.py
34+
:start-after: # delete
35+
:end-before: # end delete
36+
37+
Protect/unprotect a repository branch:
38+
39+
..literalinclude::branches.py
40+
:start-after: # protect
41+
:end-before: # end protect

‎docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Contents:
1414
install
1515
cli
1616
api-usage
17+
api-objects
1718
faq
1819
upgrade-from-0.10
1920
api/modules

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp