diff options
author | Christian <cgumpert@users.noreply.github.com> | 2017-03-21 06:50:20 +0100 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-03-21 06:50:20 +0100 |
commit | 22bf12827387cb1719bacae6c0c745cd768eee6c (patch) | |
tree | 80fd22ecc95ec6f41fb442a0ddf5d6b551822ee0 /gitlab/objects.py | |
parent | 8677f1c0250e9ab6b1e16da17d593101128cf057 (diff) | |
download | gitlab-22bf12827387cb1719bacae6c0c745cd768eee6c.tar.gz |
Provide API wrapper for cherry picking commits (#236)
Diffstat (limited to 'gitlab/objects.py')
-rw-r--r-- | gitlab/objects.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gitlab/objects.py b/gitlab/objects.py index 7c961b3..245b88f 100644 --- a/gitlab/objects.py +++ b/gitlab/objects.py @@ -1158,7 +1158,7 @@ class ProjectBranch(GitlabObject): requiredCreateAttrs = ['branch_name', 'ref'] def protect(self, protect=True, **kwargs): - """Protects the project.""" + """Protects the branch.""" url = self._url % {'project_id': self.project_id} action = 'protect' if protect else 'unprotect' url = "%s/%s/%s" % (url, self.name, action) @@ -1171,7 +1171,7 @@ class ProjectBranch(GitlabObject): del self.protected def unprotect(self, **kwargs): - """Unprotects the project.""" + """Unprotects the branch.""" self.protect(False, **kwargs) @@ -1374,6 +1374,23 @@ class ProjectCommit(GitlabObject): {'project_id': self.project_id}, **kwargs) + def cherry_pick(self, branch, **kwargs): + """Cherry-pick a commit into a branch. + + Args: + branch (str): Name of target branch. + + Raises: + GitlabCherryPickError: If the cherry pick could not be applied. + """ + url = ('/projects/%s/repository/commits/%s/cherry_pick' % + (self.project_id, self.id)) + + r = self.gitlab._raw_post(url, data={'project_id': self.project_id, + 'branch': branch}, **kwargs) + errors = {400: GitlabCherryPickError} + raise_error_from_response(r, errors, expected_code=201) + class ProjectCommitManager(BaseManager): obj_cls = ProjectCommit |