From 456552074f134e04f28d23bca38eaa9675a8c745 Mon Sep 17 00:00:00 2001 From: VBeytok <46049489+VBeytok@users.noreply.github.com> Date: Wed, 23 Jan 2019 10:24:25 +0200 Subject: [PATCH 1/6] Update Groups.php Add min_access_level got groups --- lib/Gitlab/ApiV3/Groups.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/ApiV3/Groups.php b/lib/Gitlab/ApiV3/Groups.php index dfa3ecac3..b68bbdff9 100755 --- a/lib/Gitlab/ApiV3/Groups.php +++ b/lib/Gitlab/ApiV3/Groups.php @@ -5,13 +5,15 @@ class Groups extends \Gitlab\Api\AbstractApi /** * @param int $page * @param int $per_page + * @param int $min_access_level * @return mixed */ - public function all($page = 1, $per_page = self::PER_PAGE) + public function all($page = 1, $per_page = self::PER_PAGE, $min_access_level = 10) { return $this->get('groups', array( 'page' => $page, - 'per_page' => $per_page + 'per_page' => $per_page, + 'min_access_level' => $min_access_level )); } @@ -42,6 +44,7 @@ public function show($id) * @param string $name * @param string $path * @param string $description + * @param int $visibility_level * @return mixed */ public function create($name, $path, $description = null, $visibility_level = 0) From 3a4f71972d14dedd675abc5fa984fce0aa707559 Mon Sep 17 00:00:00 2001 From: VBeytok <46049489+VBeytok@users.noreply.github.com> Date: Wed, 23 Jan 2019 11:01:23 +0200 Subject: [PATCH 2/6] Update Groups.php add min_access_level --- lib/Gitlab/Api/Groups.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Gitlab/Api/Groups.php b/lib/Gitlab/Api/Groups.php index 7009cbc09..58361d65e 100644 --- a/lib/Gitlab/Api/Groups.php +++ b/lib/Gitlab/Api/Groups.php @@ -5,13 +5,15 @@ class Groups extends AbstractApi /** * @param int $page * @param int $per_page + * @param int $min_access_level * @return mixed */ - public function all($page = 1, $per_page = self::PER_PAGE) + public function all($page = 1, $per_page = self::PER_PAGE, $min_access_level = 10) { return $this->get('groups', array( 'page' => $page, - 'per_page' => $per_page + 'per_page' => $per_page, + 'min_access_level' => $min_access_level )); } @@ -42,6 +44,7 @@ public function show($id) * @param string $name * @param string $path * @param string $description + * @param int $visibility_level * @return mixed */ public function create($name, $path, $description = null, $visibility_level = 0) From b807e7389cf07c511ef5ba9d22dbbc4bc5872fb2 Mon Sep 17 00:00:00 2001 From: VBeytok <46049489+VBeytok@users.noreply.github.com> Date: Wed, 23 Jan 2019 15:32:40 +0200 Subject: [PATCH 3/6] Update Projects.php Add min_access_level for accessible --- lib/Gitlab/Api/Projects.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/Gitlab/Api/Projects.php b/lib/Gitlab/Api/Projects.php index 39b8dac88..e4bb7c1c9 100644 --- a/lib/Gitlab/Api/Projects.php +++ b/lib/Gitlab/Api/Projects.php @@ -2,6 +2,7 @@ class Projects extends AbstractApi { + const GUEST_ACCESS_LEVEL = 10; const ORDER_BY = 'created_at'; const SORT = 'asc'; @@ -25,18 +26,28 @@ public function all($page = 1, $per_page = self::PER_PAGE, $order_by = self::ORD /** * @param int $page * @param int $per_page + * @param int $min_access_level * @param string $order_by * @param string $sort * @return mixed */ - public function accessible($page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT) - { - return $this->get('projects?membership=true', array( - 'page' => $page, - 'per_page' => $per_page, - 'order_by' => $order_by, - 'sort' => $sort - )); + public function accessible( + $page = 1, + $per_page = self::PER_PAGE, + $min_access_level = self::GUEST_ACCESS_LEVEL, + $order_by = self::ORDER_BY, + $sort = self::SORT + ) { + return $this->get( + 'projects?membership=true', + array( + 'page' => $page, + 'per_page' => $per_page, + 'min_access_level' => $min_access_level, + 'order_by' => $order_by, + 'sort' => $sort + ) + ); } /** @@ -529,4 +540,4 @@ public function uploadFile($project_id, $file) { return $this->post($this->getProjectPath($project_id, 'uploads'), array(), array(), array('file' => $file)); } -} \ No newline at end of file +} From e9f6d3561e445e2bc552d526aa27becf82ddad62 Mon Sep 17 00:00:00 2001 From: VBeytok <46049489+VBeytok@users.noreply.github.com> Date: Wed, 23 Jan 2019 15:38:17 +0200 Subject: [PATCH 4/6] Update Projects.php Add min_access_level --- lib/Gitlab/ApiV3/Projects.php | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/Gitlab/ApiV3/Projects.php b/lib/Gitlab/ApiV3/Projects.php index 2228cddba..33f40e8cd 100755 --- a/lib/Gitlab/ApiV3/Projects.php +++ b/lib/Gitlab/ApiV3/Projects.php @@ -2,6 +2,7 @@ class Projects extends \Gitlab\Api\AbstractApi { + const GUEST_ACCESS_LEVEL = 10; const ORDER_BY = 'created_at'; const SORT = 'asc'; @@ -25,18 +26,28 @@ public function all($page = 1, $per_page = self::PER_PAGE, $order_by = self::ORD /** * @param int $page * @param int $per_page + * @param int $min_access_level * @param string $order_by * @param string $sort * @return mixed */ - public function accessible($page = 1, $per_page = self::PER_PAGE, $order_by = self::ORDER_BY, $sort = self::SORT) - { - return $this->get('projects', array( - 'page' => $page, - 'per_page' => $per_page, - 'order_by' => $order_by, - 'sort' => $sort - )); + public function accessible( + $page = 1, + $per_page = self::PER_PAGE, + $min_access_level = self::GUEST_ACCESS_LEVEL, + $order_by = self::ORDER_BY, + $sort = self::SORT + ) { + return $this->get( + 'projects?membership=true', + array( + 'page' => $page, + 'per_page' => $per_page, + 'min_access_level' => $min_access_level, + 'order_by' => $order_by, + 'sort' => $sort + ) + ); } /** From b8bba9d68c250bffea6fdcd8402583df5a11f414 Mon Sep 17 00:00:00 2001 From: Yura Smetanka Date: Wed, 29 May 2019 11:57:12 +0300 Subject: [PATCH 5/6] 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); - } } From fba91914c1755d09237079a21901fb90ee33a5c3 Mon Sep 17 00:00:00 2001 From: Viktor Hryn Date: Fri, 12 Jul 2019 09:15:09 +0300 Subject: [PATCH 6/6] send data in body, except get request --- .gitignore | 1 + lib/Gitlab/HttpClient/HttpClient.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d1502b087..cbf3ce61a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +/.idea/ vendor/ composer.lock diff --git a/lib/Gitlab/HttpClient/HttpClient.php b/lib/Gitlab/HttpClient/HttpClient.php index 6b786227b..8a3508372 100644 --- a/lib/Gitlab/HttpClient/HttpClient.php +++ b/lib/Gitlab/HttpClient/HttpClient.php @@ -214,7 +214,7 @@ public function getLastResponse() */ private function createRequest($httpMethod, $url, array $parameters, array $headers, array $files) { - if (empty($files)) { + if ($httpMethod === 'GET') { $request = new Request($httpMethod); $request->setContent(http_build_query($parameters)); } else {