Skip to content

Commit b8bba9d

Browse files
yurasmetankaMykolaiKorniat
authored andcommitted
Use encodePath() instead of encodeBranch()
1 parent e9f6d35 commit b8bba9d

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

lib/Gitlab/Api/Repositories.php

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function branches($project_id, array $params = array())
1818
*/
1919
public function branch($project_id, $branch_id)
2020
{
21-
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_id)));
21+
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($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->encodeBranch($branch_name)));
45+
return $this->delete($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($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->encodeBranch($branch_name).'/protect'));
55+
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($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->encodeBranch($branch_name).'/unprotect'));
65+
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name).'/unprotect'));
6666
}
6767

6868
/**
@@ -98,7 +98,7 @@ public function createTag($project_id, $name, $ref, $message = null)
9898
* @return mixed
9999
*/
100100
public function createRelease( $project_id, $tag_name, $description ) {
101-
return $this->post( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
101+
return $this->post( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodePath( $tag_name ) . '/release' ), array(
102102
'id' => $project_id,
103103
'tag_name' => $tag_name,
104104
'description' => $description
@@ -113,7 +113,7 @@ public function createRelease( $project_id, $tag_name, $description ) {
113113
* @return mixed
114114
*/
115115
public function updateRelease( $project_id, $tag_name, $description ) {
116-
return $this->put( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
116+
return $this->put( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodePath( $tag_name ) . '/release' ), array(
117117
'id' => $project_id,
118118
'tag_name' => $tag_name,
119119
'description' => $description
@@ -203,7 +203,7 @@ public function compare($project_id, $fromShaOrMaster, $toShaOrMaster)
203203
{
204204
return $this->get($this->getProjectPath(
205205
$project_id,
206-
'repository/compare?from='.$this->encodeBranch($fromShaOrMaster).'&to='.$this->encodeBranch($toShaOrMaster)
206+
'repository/compare?from='.$this->encodePath($fromShaOrMaster).'&to='.$this->encodePath($toShaOrMaster)
207207
));
208208
}
209209

@@ -327,15 +327,4 @@ public function archive($project_id, $params = array())
327327
{
328328
return $this->get($this->getProjectPath($project_id, 'repository/archive'), $params);
329329
}
330-
331-
/**
332-
* @param string $path
333-
* @return string
334-
*/
335-
protected function encodeBranch($path)
336-
{
337-
$path = $this->encodePath($path);
338-
339-
return str_replace('%2F', '/', $path);
340-
}
341330
}

0 commit comments

Comments
 (0)