summaryrefslogtreecommitdiff
path: root/gitlab/__init__.py
diff options
context:
space:
mode:
authorStefan Klug <klug.stefan@gmx.de>2015-08-12 15:07:03 +0200
committerStefan Klug <klug.stefan@gmx.de>2015-08-12 15:07:03 +0200
commit227f71ce49cc3e0a3537a52dd2fac1d8045110f4 (patch)
treee85e227759d3d83cc50fbc14d555723a7d5a567d /gitlab/__init__.py
parent802c144cfd199684506b3404f03c3657c75e307d (diff)
downloadgitlab-227f71ce49cc3e0a3537a52dd2fac1d8045110f4.tar.gz
fix url when fetching a single MergeRequest
Diffstat (limited to 'gitlab/__init__.py')
-rw-r--r--gitlab/__init__.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 52fc7db..ae7e29b 100644
--- a/gitlab/__init__.py
+++ b/gitlab/__init__.py
@@ -190,7 +190,11 @@ class Gitlab(object):
def _construct_url(self, id_, obj, parameters):
args = _sanitize_dict(parameters)
- url = obj._url % args
+ if id_ is None and obj._urlPlural is not None:
+ url = obj._urlPlural % args
+ else:
+ url = obj._url % args
+
if id_ is not None:
url = '%s%s/%s' % (self._url, url, str(id_))
else:
@@ -616,6 +620,8 @@ class GitlabObject(object):
"""
#: Url to use in GitLab for this object
_url = None
+ #some objects (e.g. merge requests) have different urls for singular and plural
+ _urlPlural = None
_returnClass = None
_constructorTypes = None
#: Whether _get_list_or_object should return list or object when id is None
@@ -1063,7 +1069,8 @@ class ProjectMergeRequestNote(GitlabObject):
class ProjectMergeRequest(GitlabObject):
- _url = '/projects/%(project_id)s/merge_requests'
+ _url = '/projects/%(project_id)s/merge_request'
+ _urlPlural = '/projects/%(project_id)s/merge_requests'
_constructorTypes = {'author': 'User', 'assignee': 'User'}
canDelete = False
requiredUrlAttrs = ['project_id']