Skip to content

Commit 34c8a03

Browse files
author
Gauvain Pocentek
committed
Make ProjectCommitStatus.create work with CLI
Fixes #511
1 parent f2223e2 commit 34c8a03

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gitlab/v4/objects.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,7 @@ class ProjectCommitStatusManager(ListMixin, CreateMixin, RESTManager):
12011201
('description', 'name', 'context', 'ref', 'target_url',
12021202
'coverage'))
12031203

1204+
@exc.on_http_error(exc.GitlabCreateError)
12041205
def create(self, data, **kwargs):
12051206
"""Create a new object.
12061207
@@ -1218,9 +1219,15 @@ def create(self, data, **kwargs):
12181219
RESTObject: A new instance of the manage object class build with
12191220
the data sent by the server
12201221
"""
1221-
path = '/projects/%(project_id)s/statuses/%(commit_id)s'
1222-
computed_path = self._compute_path(path)
1223-
return CreateMixin.create(self, data, path=computed_path, **kwargs)
1222+
# project_id and commit_id are in the data dict when using the CLI, but
1223+
# they are missing when using only the API
1224+
# See #511
1225+
base_path = '/projects/%(project_id)s/statuses/%(commit_id)s'
1226+
if 'project_id' in data and 'commit_id' in data:
1227+
path = base_path % data
1228+
else:
1229+
path = self._compute_path(base_path)
1230+
return CreateMixin.create(self, data, path=path, **kwargs)
12241231

12251232

12261233
class ProjectCommitComment(RESTObject):

0 commit comments

Comments
 (0)