From 33710088913c96db8eb22289e693682b41054e39 Mon Sep 17 00:00:00 2001 From: Colin D Bennett Date: Wed, 30 Dec 2015 12:34:24 -0800 Subject: [PATCH] Support setting commit status Support commit status updates. Commit status can be set by a POST to the appropriate commit URL. The status can be updated by a subsequent POST to the same URL with the same `name` and `ref`, but different values for `state`, `description`, etc. Note: Listing the commit statuses is not yet supported. This is done through a different path on the server, under the `repository` path. Example of use from the CLI: # add a build status to a commit gitlab project-commit-status create --project-id 2 \ --commit-id a43290c --state success --name ci/jenkins \ --target-url http://server/build/123 \ --description "Jenkins build succeeded" --- gitlab/objects.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gitlab/objects.py b/gitlab/objects.py index 2ab2a528c..baffec8b7 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -681,6 +681,22 @@ class ProjectCommitManager(BaseManager): obj_cls = ProjectCommit +class ProjectCommitStatus(GitlabObject): + _url = '/projects/%(project_id)s/statuses/%(commit_id)s' + canUpdate = False + canDelete = False + requiredUrlAttrs = ['project_id', 'commit_id'] + requiredCreateAttrs = ['state'] + optionalCreateAttrs = ['description', 'name', 'ref', 'target_url'] + requiredGetAttrs = [] + requiredUpdateAttrs = [] + requiredDeleteAttrs = [] + + +class ProjectCommitStatusManager(BaseManager): + obj_cls = ProjectCommitStatus + + class ProjectKey(GitlabObject): _url = '/projects/%(project_id)s/keys' canUpdate = False @@ -961,6 +977,7 @@ class Project(GitlabObject): managers = [ ('branches', ProjectBranchManager, [('project_id', 'id')]), ('commits', ProjectCommitManager, [('project_id', 'id')]), + ('commitstatuses', ProjectCommitStatusManager, [('project_id', 'id')]), ('events', ProjectEventManager, [('project_id', 'id')]), ('files', ProjectFileManager, [('project_id', 'id')]), ('forks', ProjectForkManager, [('project_id', 'id')]),