diff options
author | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-07-05 16:31:10 -0300 |
---|---|---|
committer | Oswaldo Ferreira <oswaldo@gitlab.com> | 2019-07-09 14:36:29 -0300 |
commit | 84dd31493ec1a4d1463e13a3dc672f5cf5398aa3 (patch) | |
tree | 8db439885c6d85c1bf9e6389746c9930e877d48e /app/services | |
parent | ededb334c66fa25cb8518258d85b1f7da1dd8f26 (diff) | |
download | gitlab-ce-84dd31493ec1a4d1463e13a3dc672f5cf5398aa3.tar.gz |
[CE port] Bypass push rules for merge to ref serviceosw-bypass-push-rules-for-merge-to-ref
Turns out push rules to validate commit message does
not apply in the context of automatic merge to
the refs/merge-requests/:iid/merge. Mainly because
if it fails to merge to it, we currently can't give enough
preemptive feedback to the user and it'll turn the
merge request unmergeable (given we automatically
mark it as unmergeable if we can't merge to the ref).
In general, it's a systematic operation, which already
bypasses user authorization and git hooks.
Therefore, this commit makes it bypass the push rules
at EE as well.
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/merge_base_service.rb | 11 | ||||
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 4 | ||||
-rw-r--r-- | app/services/merge_requests/merge_to_ref_service.rb | 18 |
3 files changed, 16 insertions, 17 deletions
diff --git a/app/services/merge_requests/merge_base_service.rb b/app/services/merge_requests/merge_base_service.rb index 095bdca5472..1ed396cee1e 100644 --- a/app/services/merge_requests/merge_base_service.rb +++ b/app/services/merge_requests/merge_base_service.rb @@ -28,6 +28,17 @@ module MergeRequests private + def check_source + unless source + raise_error('No source for merge') + end + end + + # Overridden in EE. + def check_size_limit + # No-op + end + # Overridden in EE. def error_check! # No-op diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index d8a78001b79..3e0f5aa181c 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -48,13 +48,13 @@ module MergeRequests def error_check! super + check_source + error = if @merge_request.should_be_rebased? 'Only fast-forward merge is allowed for your project. Please update your source branch' elsif !@merge_request.mergeable? 'Merge request is not mergeable' - elsif !source - 'No source for merge' end raise_error(error) if error diff --git a/app/services/merge_requests/merge_to_ref_service.rb b/app/services/merge_requests/merge_to_ref_service.rb index 0ea50a5dbf5..37b5805ae7e 100644 --- a/app/services/merge_requests/merge_to_ref_service.rb +++ b/app/services/merge_requests/merge_to_ref_service.rb @@ -16,7 +16,7 @@ module MergeRequests def execute(merge_request) @merge_request = merge_request - validate! + error_check! commit_id = commit @@ -39,21 +39,9 @@ module MergeRequests merge_request.diff_head_sha end - def validate! - error_check! - end - + override :error_check! def error_check! - super - - error = - if !hooks_validation_pass?(merge_request) - hooks_validation_error(merge_request) - elsif source.blank? - 'No source for merge' - end - - raise_error(error) if error + check_source end ## |