@@ -18,7 +18,7 @@ public function branches($project_id)
18
18
*/
19
19
public function branch ($ project_id , $ branch_id )
20
20
{
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 )));
22
22
}
23
23
24
24
/**
@@ -42,7 +42,7 @@ public function createBranch($project_id, $branch_name, $ref)
42
42
*/
43
43
public function deleteBranch ($ project_id , $ branch_name )
44
44
{
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 )));
46
46
}
47
47
48
48
/**
@@ -52,7 +52,7 @@ public function deleteBranch($project_id, $branch_name)
52
52
*/
53
53
public function protectBranch ($ project_id , $ branch_name )
54
54
{
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 ' ));
56
56
}
57
57
58
58
/**
@@ -62,7 +62,7 @@ public function protectBranch($project_id, $branch_name)
62
62
*/
63
63
public function unprotectBranch ($ project_id , $ branch_name )
64
64
{
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 ' ));
66
66
}
67
67
68
68
/**
@@ -155,7 +155,7 @@ public function compare($project_id, $fromShaOrMaster, $toShaOrMaster)
155
155
{
156
156
return $ this ->get ($ this ->getProjectPath (
157
157
$ project_id ,
158
- 'repository/compare?from= ' .$ this ->encodePath ($ fromShaOrMaster ).'&to= ' .$ this ->encodePath ($ toShaOrMaster )
158
+ 'repository/compare?from= ' .$ this ->encodeBranch ($ fromShaOrMaster ).'&to= ' .$ this ->encodeBranch ($ toShaOrMaster )
159
159
));
160
160
}
161
161
@@ -270,4 +270,15 @@ public function contributors($project_id)
270
270
{
271
271
return $ this ->get ($ this ->getProjectPath ($ project_id , 'repository/contributors ' ));
272
272
}
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
+ }
273
284
}
0 commit comments