summaryrefslogtreecommitdiff
path: root/docs/gl_objects/commits.rst
blob: 5a43597a555578a59ea14bc10d6a9654e5e20f84 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#######
Commits
#######

Commits
=======

Use :class:`~gitlab.objects.ProjectCommit` objects to manipulate commits. The
:attr:`gitlab.Gitlab.project_commits` and
:attr:`gitlab.objects.Project.commits` manager objects provide helper
functions.

Examples
--------

List the commits for a project:

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

You can use the ``ref_name``, ``since`` and ``until`` filters to limit the
results:

.. literalinclude:: commits.py
   :start-after: # filter list
   :end-before: # end filter list

Get a commit detail:

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

Get the diff for a commit:

.. literalinclude:: commits.py
   :start-after: # diff
   :end-before: # end diff

Commit comments
===============

Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits. The
:attr:`gitlab.Gitlab.project_commit_comments` and
:attr:`gitlab.objects.Project.commit_comments` and
:attr:`gitlab.objects.ProjectCommit.comments` manager objects provide helper
functions.

Examples
--------

Get the comments for a commit:

.. literalinclude:: commits.py
   :start-after: # comments list
   :end-before: # end comments list

Add a comment on a commit:

.. literalinclude:: commits.py
   :start-after: # comments create
   :end-before: # end comments create

Commit status
=============

Use :class:`~gitlab.objects.ProjectCommitStatus` objects to manipulate commits.
The :attr:`gitlab.Gitlab.project_commit_statuses`,
:attr:`gitlab.objects.Project.commit_statuses` and
:attr:`gitlab.objects.ProjectCommit.statuses` manager objects provide helper
functions.

Examples
--------

Get the statuses for a commit:

.. literalinclude:: commits.py
   :start-after: # statuses list
   :end-before: # end statuses list

Change the status of a commit:

.. literalinclude:: commits.py
   :start-after: # statuses set
   :end-before: # end statuses set