diff options
author | Max Wittig <max.wittig@siemens.com> | 2020-02-20 09:06:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 09:06:23 +0100 |
commit | e8f0921d164c4b7db78e2f62e75eb32094b4456e (patch) | |
tree | d603f98235d9bfb6b1968a4e3412bb0d8efe72ba /gitlab/v4/objects.py | |
parent | 19242c398b9074e04e35cc687c31c543a10db280 (diff) | |
parent | cb436951b1fde9c010e966819c75d0d7adacf17d (diff) | |
download | gitlab-e8f0921d164c4b7db78e2f62e75eb32094b4456e.tar.gz |
Merge pull request #1020 from nejch/feat/revert-commit-api
feat: add support for commit revert API (#991)
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r-- | gitlab/v4/objects.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index b31870c..83f77d3 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -2136,6 +2136,26 @@ class ProjectCommit(RESTObject): path = "%s/%s/merge_requests" % (self.manager.path, self.get_id()) return self.manager.gitlab.http_get(path, **kwargs) + @cli.register_custom_action("ProjectCommit", ("branch",)) + @exc.on_http_error(exc.GitlabRevertError) + def revert(self, branch, **kwargs): + """Revert a commit on a given branch. + + Args: + branch (str): Name of target branch + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabRevertError: If the revert could not be performed + + Returns: + dict: The new commit data (*not* a RESTObject) + """ + path = "%s/%s/revert" % (self.manager.path, self.get_id()) + post_data = {"branch": branch} + return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) + class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager): _path = "/projects/%(project_id)s/repository/commits" |