@@ -18,7 +18,7 @@ public function branches($project_id)
1818 */
1919 public function branch ($ project_id , $ branch_id )
2020 {
21- return $ this ->get ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodePath ($ branch_id )));
21+ return $ this ->get ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodeBranch ($ branch_id )));
2222 }
2323
2424 /**
@@ -42,7 +42,7 @@ public function createBranch($project_id, $branch_name, $ref)
4242 */
4343 public function deleteBranch ($ project_id , $ branch_name )
4444 {
45- return $ this ->delete ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodePath ($ branch_name )));
45+ return $ this ->delete ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodeBranch ($ branch_name )));
4646 }
4747
4848 /**
@@ -52,7 +52,7 @@ public function deleteBranch($project_id, $branch_name)
5252 */
5353 public function protectBranch ($ project_id , $ branch_name )
5454 {
55- return $ this ->put ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodePath ($ branch_name ).'/protect ' ));
55+ return $ this ->put ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodeBranch ($ branch_name ).'/protect ' ));
5656 }
5757
5858 /**
@@ -62,7 +62,7 @@ public function protectBranch($project_id, $branch_name)
6262 */
6363 public function unprotectBranch ($ project_id , $ branch_name )
6464 {
65- return $ this ->put ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodePath ($ branch_name ).'/unprotect ' ));
65+ return $ this ->put ($ this ->getProjectPath ($ project_id , 'repository/branches/ ' .$ this ->encodeBranch ($ branch_name ).'/unprotect ' ));
6666 }
6767
6868 /**
@@ -155,7 +155,7 @@ public function compare($project_id, $fromShaOrMaster, $toShaOrMaster)
155155 {
156156 return $ this ->get ($ this ->getProjectPath (
157157 $ project_id ,
158- 'repository/compare?from= ' .$ this ->encodePath ($ fromShaOrMaster ).'&to= ' .$ this ->encodePath ($ toShaOrMaster )
158+ 'repository/compare?from= ' .$ this ->encodeBranch ($ fromShaOrMaster ).'&to= ' .$ this ->encodeBranch ($ toShaOrMaster )
159159 ));
160160 }
161161
@@ -270,4 +270,15 @@ public function contributors($project_id)
270270 {
271271 return $ this ->get ($ this ->getProjectPath ($ project_id , 'repository/contributors ' ));
272272 }
273+
274+ /**
275+ * @param string $path
276+ * @return string
277+ */
278+ protected function encodeBranch ($ path )
279+ {
280+ $ path = $ this ->encodePath ($ path );
281+
282+ return str_replace ('%2F ' , '/ ' , $ path );
283+ }
273284}
0 commit comments