diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-06-06 08:10:47 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-06-06 08:10:47 +0200 |
commit | 34c8a03462e4ac9e3a7cf7f591ec19d17ac6e0bc (patch) | |
tree | 21b7201efdec64c099de18d4c20d5230b88379e9 /gitlab/v4/objects.py | |
parent | f2223e2397aebd1a805bae25b0d6a5fc58519d5d (diff) | |
download | gitlab-34c8a03462e4ac9e3a7cf7f591ec19d17ac6e0bc.tar.gz |
Make ProjectCommitStatus.create work with CLI
Fixes #511
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r-- | gitlab/v4/objects.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index 8dc6171..4c2ec45 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -1201,6 +1201,7 @@ class ProjectCommitStatusManager(ListMixin, CreateMixin, RESTManager): ('description', 'name', 'context', 'ref', 'target_url', 'coverage')) + @exc.on_http_error(exc.GitlabCreateError) def create(self, data, **kwargs): """Create a new object. @@ -1218,9 +1219,15 @@ class ProjectCommitStatusManager(ListMixin, CreateMixin, RESTManager): RESTObject: A new instance of the manage object class build with the data sent by the server """ - path = '/projects/%(project_id)s/statuses/%(commit_id)s' - computed_path = self._compute_path(path) - return CreateMixin.create(self, data, path=computed_path, **kwargs) + # project_id and commit_id are in the data dict when using the CLI, but + # they are missing when using only the API + # See #511 + base_path = '/projects/%(project_id)s/statuses/%(commit_id)s' + if 'project_id' in data and 'commit_id' in data: + path = base_path % data + else: + path = self._compute_path(base_path) + return CreateMixin.create(self, data, path=path, **kwargs) class ProjectCommitComment(RESTObject): |