From 9c61f8b2a99965c8b213bba055ad3aaca60fe7fa Mon Sep 17 00:00:00 2001 From: Matt Humphrey Date: Fri, 25 Jan 2013 14:33:47 +0000 Subject: [PATCH 1/2] Added methods to protect and unprotect repo branches. --- lib/api/projects.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index cbef1ed3b50..a039baed044 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -233,6 +233,32 @@ module Gitlab present @branch, with: Entities::RepoObject end + # Protect a single branch + # + # Parameters: + # id (required) - The ID of a project + # branch (required) - The name of the branch + # Example Request: + # GET /projects/:id/repository/branches/:branch/protect + post ":id/repository/branches/:branch/protect" do + @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } + user_project.protected_branches.create(:name => @branch.name) + present @branch, with: Entities::RepoObject + end + + # Unprotect a single branch + # + # Parameters: + # id (required) - The ID of a project + # branch (required) - The name of the branch + # Example Request: + # GET /projects/:id/repository/branches/:branch/unprotect + post ":id/repository/branches/:branch/unprotect" do + @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } + user_project.protected_branches.find_by_name(@branch.name).destroy + present @branch, with: Entities::RepoObject + end + # Get a project repository tags # # Parameters: -- GitLab From 8a19aff6241a32a407c4e800d1bf8e7c3e6f4750 Mon Sep 17 00:00:00 2001 From: Matt Humphrey Date: Mon, 28 Jan 2013 17:01:04 +0000 Subject: [PATCH 2/2] Revert "Added methods to protect and unprotect repo branches." so can be moved into branch --- lib/api/projects.rb | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index a039baed044..cbef1ed3b50 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -233,32 +233,6 @@ module Gitlab present @branch, with: Entities::RepoObject end - # Protect a single branch - # - # Parameters: - # id (required) - The ID of a project - # branch (required) - The name of the branch - # Example Request: - # GET /projects/:id/repository/branches/:branch/protect - post ":id/repository/branches/:branch/protect" do - @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } - user_project.protected_branches.create(:name => @branch.name) - present @branch, with: Entities::RepoObject - end - - # Unprotect a single branch - # - # Parameters: - # id (required) - The ID of a project - # branch (required) - The name of the branch - # Example Request: - # GET /projects/:id/repository/branches/:branch/unprotect - post ":id/repository/branches/:branch/unprotect" do - @branch = user_project.repo.heads.find { |item| item.name == params[:branch] } - user_project.protected_branches.find_by_name(@branch.name).destroy - present @branch, with: Entities::RepoObject - end - # Get a project repository tags # # Parameters: -- GitLab