Skip to content

Commit 92180e4

Browse files
author
Gauvain Pocentek
committed
Implement merge requests diff support
1 parent c970a22 commit 92180e4

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

docs/gl_objects/mrs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,11 @@
6363
# todo
6464
mr.todo()
6565
# end todo
66+
67+
# diff list
68+
diffs = mr.diffs.list()
69+
# end diff list
70+
71+
# diff get
72+
diff = mr.diffs.get(diff_id)
73+
# end diff get

docs/gl_objects/mrs.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
Merge requests
33
##############
44

5-
Use :class:`~gitlab.objects.ProjectMergeRequest` objects to manipulate MRs for
6-
projects. The :attr:`gitlab.Gitlab.project_mergerequests` and
7-
:attr:`Project.mergerequests <gitlab.objects.Project.mergerequests>` manager
8-
objects provide helper functions.
5+
You can use merge requests to notify a project that a branch is ready for
6+
merging. The owner of the target projet can accept the merge request.
7+
8+
* Object class: :class:`~gitlab.objects.ProjectMergeRequest`
9+
* Manager objects: :attr:`gitlab.Gitlab.project_mergerequests`,
10+
:attr:`Project.mergerequests <gitlab.objects.Project.mergerequests>`
911

1012
Examples
1113
--------
@@ -89,3 +91,15 @@ Mark a MR as todo:
8991
.. literalinclude:: mrs.py
9092
:start-after: # todo
9193
:end-before: # end todo
94+
95+
List the diffs for a merge request:
96+
97+
.. literalinclude:: mrs.py
98+
:start-after: # diff list
99+
:end-before: # end diff list
100+
101+
Get a diff for a merge request:
102+
103+
.. literalinclude:: mrs.py
104+
:start-after: # diff get
105+
:end-before: # end diff get

gitlab/objects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,19 @@ class ProjectTagManager(BaseManager):
15121512
obj_cls = ProjectTag
15131513

15141514

1515+
class ProjectMergeRequestDiff(GitlabObject):
1516+
_url = ('/projects/%(project_id)s/merge_requests/'
1517+
'%(merge_request_id)s/versions')
1518+
canCreate = False
1519+
canUpdate = False
1520+
canDelete = False
1521+
requiredUrlAttrs = ['project_id', 'merge_request_id']
1522+
1523+
1524+
class ProjectMergeRequestDiffManager(BaseManager):
1525+
obj_cls = ProjectMergeRequestDiff
1526+
1527+
15151528
class ProjectMergeRequestNote(GitlabObject):
15161529
_url = '/projects/%(project_id)s/merge_requests/%(merge_request_id)s/notes'
15171530
_constructorTypes = {'author': 'User'}
@@ -1539,6 +1552,8 @@ class ProjectMergeRequest(GitlabObject):
15391552
managers = (
15401553
('notes', ProjectMergeRequestNoteManager,
15411554
[('project_id', 'project_id'), ('merge_request_id', 'id')]),
1555+
('diffs', ProjectMergeRequestDiffManager,
1556+
[('project_id', 'project_id'), ('merge_request_id', 'id')]),
15421557
)
15431558

15441559
def _data_for_gitlab(self, extra_parameters={}, update=False,

0 commit comments

Comments
 (0)