@@ -1158,7 +1158,7 @@ class ProjectBranch(GitlabObject):
1158
1158
requiredCreateAttrs = ['branch_name' , 'ref' ]
1159
1159
1160
1160
def protect (self , protect = True , ** kwargs ):
1161
- """Protects the project ."""
1161
+ """Protects the branch ."""
1162
1162
url = self ._url % {'project_id' : self .project_id }
1163
1163
action = 'protect' if protect else 'unprotect'
1164
1164
url = "%s/%s/%s" % (url , self .name , action )
@@ -1171,7 +1171,7 @@ def protect(self, protect=True, **kwargs):
1171
1171
del self .protected
1172
1172
1173
1173
def unprotect (self , ** kwargs ):
1174
- """Unprotects the project ."""
1174
+ """Unprotects the branch ."""
1175
1175
self .protect (False , ** kwargs )
1176
1176
1177
1177
@@ -1374,6 +1374,23 @@ def builds(self, **kwargs):
1374
1374
{'project_id' : self .project_id },
1375
1375
** kwargs )
1376
1376
1377
+ def cherry_pick (self , branch , ** kwargs ):
1378
+ """Cherry-pick a commit into a branch.
1379
+
1380
+ Args:
1381
+ branch (str): Name of target branch.
1382
+
1383
+ Raises:
1384
+ GitlabCherryPickError: If the cherry pick could not be applied.
1385
+ """
1386
+ url = ('/projects/%s/repository/commits/%s/cherry_pick' %
1387
+ (self .project_id , self .id ))
1388
+
1389
+ r = self .gitlab ._raw_post (url , data = {'project_id' : self .project_id ,
1390
+ 'branch' : branch }, ** kwargs )
1391
+ errors = {400 : GitlabCherryPickError }
1392
+ raise_error_from_response (r , errors , expected_code = 201 )
1393
+
1377
1394
1378
1395
class ProjectCommitManager (BaseManager ):
1379
1396
obj_cls = ProjectCommit
0 commit comments