Commit 23a98653 authored by James Ramsay's avatar James Ramsay

Add committer approval API attribute

Merge Requests Approvals can be restricted to prevent the merge
request author or merge request committers from self approving. The
author restriction is already available in the API, but the committer
restriction was not.
parent 67bfae0b
---
title: Add missing merge request committer approval setting to API
merge_request: 15019
author: jramsay
type: changed
...@@ -28,8 +28,9 @@ module API ...@@ -28,8 +28,9 @@ module API
optional :approvals_before_merge, type: Integer, desc: 'The amount of approvals required before an MR can be merged' optional :approvals_before_merge, type: Integer, desc: 'The amount of approvals required before an MR can be merged'
optional :reset_approvals_on_push, type: Boolean, desc: 'Should the approval count be reset on a new push' optional :reset_approvals_on_push, type: Boolean, desc: 'Should the approval count be reset on a new push'
optional :disable_overriding_approvers_per_merge_request, type: Boolean, desc: 'Should MRs be able to override approvers and approval count' optional :disable_overriding_approvers_per_merge_request, type: Boolean, desc: 'Should MRs be able to override approvers and approval count'
optional :merge_requests_author_approval, type: Boolean, desc: 'Should authors be able to self approve merge requests' optional :merge_requests_author_approval, type: Boolean, desc: 'Should merge request authors be able to self approve merge requests; `true` means authors cannot self approve'
at_least_one_of :approvals_before_merge, :reset_approvals_on_push, :disable_overriding_approvers_per_merge_request, :merge_requests_author_approval optional :merge_requests_disable_committers_approval, type: Boolean, desc: 'Should committers be able to self approve merge requests'
at_least_one_of :approvals_before_merge, :reset_approvals_on_push, :disable_overriding_approvers_per_merge_request, :merge_requests_author_approval, :merge_requests_disable_committers_approval
end end
post '/' do post '/' do
project_params = declared(params, include_missing: false, include_parent_namespaces: false) project_params = declared(params, include_missing: false, include_parent_namespaces: false)
......
...@@ -367,6 +367,7 @@ module EE ...@@ -367,6 +367,7 @@ module EE
expose :reset_approvals_on_push expose :reset_approvals_on_push
expose :disable_overriding_approvers_per_merge_request expose :disable_overriding_approvers_per_merge_request
expose :merge_requests_author_approval expose :merge_requests_author_approval
expose :merge_requests_disable_committers_approval
end end
class Approvals < Grape::Entity class Approvals < Grape::Entity
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"disable_overriding_approvers_per_merge_request": { "type": ["boolean", "null"] }, "disable_overriding_approvers_per_merge_request": { "type": ["boolean", "null"] },
"reset_approvals_on_push": { "type": "boolean" }, "reset_approvals_on_push": { "type": "boolean" },
"merge_requests_author_approval": { "type": ["boolean", "null"] }, "merge_requests_author_approval": { "type": ["boolean", "null"] },
"merge_requests_disable_committers_approval": { "type": ["boolean", "null"] },
"approvers": { "approvers": {
"type": "array", "type": "array",
"items": { "items": {
......
...@@ -66,13 +66,15 @@ describe API::ProjectApprovals do ...@@ -66,13 +66,15 @@ describe API::ProjectApprovals do
project.reset_approvals_on_push = false project.reset_approvals_on_push = false
project.disable_overriding_approvers_per_merge_request = true project.disable_overriding_approvers_per_merge_request = true
project.merge_requests_author_approval = false project.merge_requests_author_approval = false
project.merge_requests_disable_committers_approval = true
project.save project.save
settings = { settings = {
approvals_before_merge: 4, approvals_before_merge: 4,
reset_approvals_on_push: true, reset_approvals_on_push: true,
disable_overriding_approvers_per_merge_request: false, disable_overriding_approvers_per_merge_request: false,
merge_requests_author_approval: true merge_requests_author_approval: true,
merge_requests_disable_committers_approval: false
} }
post api(url, current_user), params: settings post api(url, current_user), params: settings
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment