Skip to content

Commit

Permalink
Use encodePath() instead of encodeBranch()
Browse files Browse the repository at this point in the history
  • Loading branch information
yurasmetanka authored and MykolaiKorniat committed May 29, 2019
1 parent e9f6d35 commit b8bba9d
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions lib/Gitlab/Api/Repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function branches($project_id, array $params = array())
*/
public function branch($project_id, $branch_id)
{
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_id)));
return $this->get($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_id)));
}

/**
Expand All @@ -42,7 +42,7 @@ public function createBranch($project_id, $branch_name, $ref)
*/
public function deleteBranch($project_id, $branch_name)
{
return $this->delete($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_name)));
return $this->delete($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name)));
}

/**
Expand All @@ -52,7 +52,7 @@ public function deleteBranch($project_id, $branch_name)
*/
public function protectBranch($project_id, $branch_name)
{
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_name).'/protect'));
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name).'/protect'));
}

/**
Expand All @@ -62,7 +62,7 @@ public function protectBranch($project_id, $branch_name)
*/
public function unprotectBranch($project_id, $branch_name)
{
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodeBranch($branch_name).'/unprotect'));
return $this->put($this->getProjectPath($project_id, 'repository/branches/'.$this->encodePath($branch_name).'/unprotect'));
}

/**
Expand Down Expand Up @@ -98,7 +98,7 @@ public function createTag($project_id, $name, $ref, $message = null)
* @return mixed
*/
public function createRelease( $project_id, $tag_name, $description ) {
return $this->post( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
return $this->post( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodePath( $tag_name ) . '/release' ), array(
'id' => $project_id,
'tag_name' => $tag_name,
'description' => $description
Expand All @@ -113,7 +113,7 @@ public function createRelease( $project_id, $tag_name, $description ) {
* @return mixed
*/
public function updateRelease( $project_id, $tag_name, $description ) {
return $this->put( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodeBranch( $tag_name ) . '/release' ), array(
return $this->put( $this->getProjectPath( $project_id, 'repository/tags/' . $this->encodePath( $tag_name ) . '/release' ), array(
'id' => $project_id,
'tag_name' => $tag_name,
'description' => $description
Expand Down Expand Up @@ -203,7 +203,7 @@ public function compare($project_id, $fromShaOrMaster, $toShaOrMaster)
{
return $this->get($this->getProjectPath(
$project_id,
'repository/compare?from='.$this->encodeBranch($fromShaOrMaster).'&to='.$this->encodeBranch($toShaOrMaster)
'repository/compare?from='.$this->encodePath($fromShaOrMaster).'&to='.$this->encodePath($toShaOrMaster)
));
}

Expand Down Expand Up @@ -327,15 +327,4 @@ public function archive($project_id, $params = array())
{
return $this->get($this->getProjectPath($project_id, 'repository/archive'), $params);
}

/**
* @param string $path
* @return string
*/
protected function encodeBranch($path)
{
$path = $this->encodePath($path);

return str_replace('%2F', '/', $path);
}
}

0 comments on commit b8bba9d

Please sign in to comment.