diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-07-12 16:31:55 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-07-19 11:11:56 +0200 |
commit | 54d26c89f66abb2bfec7403fd6b3ed7700e73766 (patch) | |
tree | 7ee19c7d2ea3f2c57f739a3d97dbae04a7daafd0 /lib/api/branches.rb | |
parent | 78cd5b8d0e0a69d7b1681bf98b17ccb7a22dde5f (diff) | |
download | gitlab-ce-54d26c89f66abb2bfec7403fd6b3ed7700e73766.tar.gz |
API: Expose 'developers_can_push' for branches
Diffstat (limited to 'lib/api/branches.rb')
-rw-r--r-- | lib/api/branches.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index d467eb9d474..cd33091d9f4 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -36,6 +36,7 @@ module API # Parameters: # id (required) - The ID of a project # branch (required) - The name of the branch + # developers_can_push (optional) - Flag if developers can push to that branch # Example Request: # PUT /projects/:id/repository/branches/:branch/protect put ':id/repository/branches/:branch/protect', @@ -43,9 +44,16 @@ module API authorize_admin_project @branch = user_project.repository.find_branch(params[:branch]) - not_found!("Branch") unless @branch + not_found!('Branch') unless @branch protected_branch = user_project.protected_branches.find_by(name: @branch.name) - user_project.protected_branches.create(name: @branch.name) unless protected_branch + developers_can_push = to_boolean(params[:developers_can_push]) + + if protected_branch + protected_branch.update(developers_can_push: developers_can_push) unless developers_can_push.nil? + else + user_project.protected_branches.create(name: @branch.name, + developers_can_push: developers_can_push || false) + end present @branch, with: Entities::RepoObject, project: user_project end |