From 608aaf7db08b561aa890b08803a5e389cdbc7c96 Mon Sep 17 00:00:00 2001 From: Flavien BINET Date: Tue, 15 Apr 2014 20:09:06 +0200 Subject: [PATCH] Added Branches API --- lib/Gitlab/Api/Branches.php | 33 +++++++++++++++++++++++++++++++++ lib/Gitlab/Client.php | 4 ++++ 2 files changed, 37 insertions(+) create mode 100644 lib/Gitlab/Api/Branches.php diff --git a/lib/Gitlab/Api/Branches.php b/lib/Gitlab/Api/Branches.php new file mode 100644 index 000000000..3aaaec05b --- /dev/null +++ b/lib/Gitlab/Api/Branches.php @@ -0,0 +1,33 @@ +get(sprintf("/projects/%s/repository/branches", urlencode($projectId))); + } + + public function show($projectId, $branchName) + { + return $this->get(sprintf("/projects/%s/repository/branches/%s", urlencode($projectId), urlencode($branchName))); + } + + public function protect($projectId, $branchName) + { + return $this->put(sprintf("/projects/%s/repository/branches/%s/protect", urlencode($projectId), urlencode($branchName))); + } + + public function unprotect($projectId, $branchName) + { + return $this->put(sprintf("/projects/%s/repository/branches/%s/unprotect", urlencode($projectId), urlencode($branchName))); + } + + public function create($projectId, $branchName, $ref) + { + $params = array('branch_name' => $branchName, 'ref' => $ref); + + return $this->post(sprintf("/projects/%s/repository/branches", urlencode($projectId)), $params); + } +} \ No newline at end of file diff --git a/lib/Gitlab/Client.php b/lib/Gitlab/Client.php index 4277355fb..662e9a4b2 100644 --- a/lib/Gitlab/Client.php +++ b/lib/Gitlab/Client.php @@ -74,6 +74,10 @@ public function api($name) $api = new Api\Users($this); break; + case 'branches': + $api = new Api\Branches($this); + break; + case 'projects': $api = new Api\Projects($this); break;