Skip to content

Commit 11b4bbd

Browse files
committed
Added support for unprotecting branches.
1 parent 5c7f1fc commit 11b4bbd

3 files changed

Lines changed: 19 additions & 0 deletions

File tree

‎lib/Gitlab/Api/Repositories.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public function protectBranch($project_id, $branch_id)
3030
return $this->post('projects/'.urlencode($project_id).'/repository/branches/'.urlencode($branch_id).'/protect');
3131
}
3232

33+
public function unprotectBranch($project_id, $branch_id)
34+
{
35+
return $this->post('projects/'.urlencode($project_id).'/repository/branches/'.urlencode($branch_id).'/unprotect');
36+
}
37+
3338
}

‎lib/Gitlab/Model/Branch.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ public function protect()
4141
return Branch::fromArray($this->project, $data);
4242
}
4343

44+
public function unprotect()
45+
{
46+
$data = $this->api('repositories')->unprotectBranch($this->project->id, $this->name);
47+
48+
return Branch::fromArray($this->project, $data);
49+
}
50+
4451
}

‎lib/Gitlab/Model/Project.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@ public function protectBranch($branch_name)
142142
return $branch->protect();
143143
}
144144

145+
public function unprotectBranch($branch_name)
146+
{
147+
$branch = new Branch($this, $branch_name);
148+
149+
return $branch->unprotect();
150+
}
151+
145152
public function tags()
146153
{
147154
$data = $this->api('repo')->tags($this->id);

0 commit comments

Comments
 (0)