diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2016-07-19 10:36:18 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2016-07-19 10:44:52 +0200 |
commit | ab9ea51dd2556d8cffe747986162cdf77c52f64d (patch) | |
tree | d52eb5b14067406aa7c0eaf40b53f84688192641 /lib/api | |
parent | 8f4e0d9d55b5d9b01d6c2de00091c68d41e7bf27 (diff) | |
download | gitlab-ce-api-dev-can-push.tar.gz |
API: Expose 'developers_can_merge' for branchesapi-dev-can-push
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/branches.rb | 6 | ||||
-rw-r--r-- | lib/api/entities.rb | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/branches.rb b/lib/api/branches.rb index cd33091d9f4..b77eebc729a 100644 --- a/lib/api/branches.rb +++ b/lib/api/branches.rb @@ -37,6 +37,7 @@ module API # 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 + # developers_can_merge (optional) - Flag if developers can merge to that branch # Example Request: # PUT /projects/:id/repository/branches/:branch/protect put ':id/repository/branches/:branch/protect', @@ -47,12 +48,15 @@ module API not_found!('Branch') unless @branch protected_branch = user_project.protected_branches.find_by(name: @branch.name) developers_can_push = to_boolean(params[:developers_can_push]) + developers_can_merge = to_boolean(params[:developers_can_merge]) if protected_branch protected_branch.update(developers_can_push: developers_can_push) unless developers_can_push.nil? + protected_branch.update(developers_can_merge: developers_can_merge) unless developers_can_merge.nil? else user_project.protected_branches.create(name: @branch.name, - developers_can_push: developers_can_push || false) + developers_can_push: developers_can_push || false, + developers_can_merge: developers_can_merge || false) end present @branch, with: Entities::RepoObject, project: user_project diff --git a/lib/api/entities.rb b/lib/api/entities.rb index e4ae5adafd6..d6fed1a1eed 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -136,6 +136,12 @@ module API options[:project].developers_can_push_to_protected_branch? repo_obj.name end end + + expose :developers_can_merge do |repo_obj, options| + if options[:project] + options[:project].developers_can_merge_to_protected_branch? repo_obj.name + end + end end class RepoTreeObject < Grape::Entity |