summaryrefslogtreecommitdiff
path: root/docs/gl_objects/commits.rst
blob: 9267cae18efdb72582d308da7d3b3441b9db9840 (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#######
Commits
#######

Commits
=======

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectCommit`
  + :class:`gitlab.v4.objects.ProjectCommitManager`
  + :attr:`gitlab.v4.objects.Project.commits`

* v3 API:

  + :class:`gitlab.v3.objects.ProjectCommit`
  + :class:`gitlab.v3.objects.ProjectCommitManager`
  + :attr:`gitlab.v3.objects.Project.commits`
  + :attr:`gitlab.Gitlab.project_commits`

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


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

Create a commit:

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

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

Cherry-pick a commit into another branch:

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

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

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectCommitComment`
  + :class:`gitlab.v4.objects.ProjectCommitCommentManager`
  + :attr:`gitlab.v4.objects.Commit.comments`

* v3 API:

  + :class:`gitlab.v3.objects.ProjectCommit`
  + :class:`gitlab.v3.objects.ProjectCommitManager`
  + :attr:`gitlab.v3.objects.Commit.comments`
  + :attr:`gitlab.v3.objects.Project.commit_comments`
  + :attr:`gitlab.Gitlab.project_commit_comments`

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

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
=============

Reference
---------

* v4 API:

  + :class:`gitlab.v4.objects.ProjectCommitStatus`
  + :class:`gitlab.v4.objects.ProjectCommitStatusManager`
  + :attr:`gitlab.v4.objects.Commit.statuses`

* v3 API:

  + :class:`gitlab.v3.objects.ProjectCommit`
  + :class:`gitlab.v3.objects.ProjectCommitManager`
  + :attr:`gitlab.v3.objects.Commit.statuses`
  + :attr:`gitlab.v3.objects.Project.commit_statuses`
  + :attr:`gitlab.Gitlab.project_commit_statuses`

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

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