From b8bba9d68c250bffea6fdcd8402583df5a11f414 Mon Sep 17 00:00:00 2001 From: Yura Smetanka Date: Wed, 29 May 2019 11:57:12 +0300 Subject: [PATCH] Use encodePath() instead of encodeBranch() --- lib/Gitlab/Api/Repositories.php | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/lib/Gitlab/Api/Repositories.php b/lib/Gitlab/Api/Repositories.php index 1905953d4..7f842ca99 100644 --- a/lib/Gitlab/Api/Repositories.php +++ b/lib/Gitlab/Api/Repositories.php @@ -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))); } /** @@ -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))); } /** @@ -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')); } /** @@ -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')); } /** @@ -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 @@ -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 @@ -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) )); } @@ -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); - } }