Skip to content

Commit 736fece

Browse files
author
Gauvain Pocentek
committed
Fix URL encoding on branch methods
Fixes #493
1 parent 86a8251 commit 736fece

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

gitlab/v4/objects.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,8 @@ def protect(self, developers_can_push=False, developers_can_merge=False,
882882
GitlabAuthenticationError: If authentication is not correct
883883
GitlabProtectError: If the branch could not be protected
884884
"""
885-
path = '%s/%s/protect' % (self.manager.path, self.get_id())
885+
id = self.get_id().replace('/', '%2F')
886+
path = '%s/%s/protect' % (self.manager.path, id)
886887
post_data = {'developers_can_push': developers_can_push,
887888
'developers_can_merge': developers_can_merge}
888889
self.manager.gitlab.http_put(path, post_data=post_data, **kwargs)
@@ -900,7 +901,8 @@ def unprotect(self, **kwargs):
900901
GitlabAuthenticationError: If authentication is not correct
901902
GitlabProtectError: If the branch could not be unprotected
902903
"""
903-
path = '%s/%s/unprotect' % (self.manager.path, self.get_id())
904+
id = self.get_id().replace('/', '%2F')
905+
path = '%s/%s/unprotect' % (self.manager.path, id)
904906
self.manager.gitlab.http_put(path, **kwargs)
905907
self._attrs['protected'] = False
906908

0 commit comments

Comments
 (0)