summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2015-08-21 12:15:37 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2015-08-21 12:15:37 +0200
commitadbe0a4391f1e3b4d615ef7966dfa66e75b9a6fa (patch)
treef3f3a2c1184842bda05604a519b44936d57daaf3 /gitlab
parent802c144cfd199684506b3404f03c3657c75e307d (diff)
parent79d452d3ebf73d4385eb3b259d7c0bab8f914241 (diff)
downloadgitlab-adbe0a4391f1e3b4d615ef7966dfa66e75b9a6fa.tar.gz
Merge pull request #66 from stefanklug/master
Fix error when fetching single MergeRequests
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/__init__.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py
index 52fc7db..43b139d 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
@@ -1056,14 +1062,14 @@ class ProjectTag(GitlabObject):
class ProjectMergeRequestNote(GitlabObject):
_url = '/projects/%(project_id)s/merge_requests/%(merge_request_id)s/notes'
_constructorTypes = {'author': 'User'}
- canUpdate = False
canDelete = False
requiredUrlAttrs = ['project_id', 'merge_request_id']
requiredCreateAttrs = ['body']
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']