diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 06:09:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-07 06:09:15 +0300 |
commit | 7ba5b9babaa5802c39e686c57cbf4a3f4725c4b0 (patch) | |
tree | 03a696c26f32e46faa46dd12d0a937d1d0d1cba4 /app/services/merge_requests | |
parent | b56027c9d80ac0e297ba8a43c81e8504172dbf9f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/merge_requests')
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 3 | ||||
-rw-r--r-- | app/services/merge_requests/post_merge_service.rb | 23 | ||||
-rw-r--r-- | app/services/merge_requests/squash_service.rb | 14 |
3 files changed, 10 insertions, 30 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index 3405ea389f8..31097b9151a 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -27,7 +27,6 @@ module MergeRequests success end end - log_info("Merge process finished on JID #{merge_jid} with state #{state}") rescue MergeError => e handle_merge_error(log_message: e.message, save_message_on_model: true) @@ -55,7 +54,7 @@ module MergeRequests error = if @merge_request.should_be_rebased? 'Only fast-forward merge is allowed for your project. Please update your source branch' - elsif !@merge_request.merged? && !@merge_request.mergeable? + elsif !@merge_request.mergeable? 'Merge request is not mergeable' end diff --git a/app/services/merge_requests/post_merge_service.rb b/app/services/merge_requests/post_merge_service.rb index a3d7f623546..0364c0dd479 100644 --- a/app/services/merge_requests/post_merge_service.rb +++ b/app/services/merge_requests/post_merge_service.rb @@ -8,28 +8,17 @@ module MergeRequests # class PostMergeService < MergeRequests::BaseService def execute(merge_request) - # These operations need to happen transactionally - ActiveRecord::Base.transaction(requires_new: true) do - merge_request.mark_as_merged - - # These options do not call external services and should be - # relatively quick enough to put in a Transaction - create_event(merge_request) - todo_service.merge_merge_request(merge_request, current_user) - end - - # These operations are idempotent so can be safely run multiple times - notification_service.merge_mr(merge_request, current_user) - create_note(merge_request) + merge_request.mark_as_merged close_issues(merge_request) + todo_service.merge_merge_request(merge_request, current_user) + create_event(merge_request) + create_note(merge_request) + notification_service.merge_mr(merge_request, current_user) + execute_hooks(merge_request, 'merge') invalidate_cache_counts(merge_request, users: merge_request.assignees) merge_request.update_project_counter_caches delete_non_latest_diffs(merge_request) cleanup_environments(merge_request) - - # Anything after this point will be executed at-most-once. Less important activity only - # TODO: make all the work in here a separate sidekiq job so it can go in the transaction - execute_hooks(merge_request, 'merge') end private diff --git a/app/services/merge_requests/squash_service.rb b/app/services/merge_requests/squash_service.rb index 09d867f39ae..d25997c925e 100644 --- a/app/services/merge_requests/squash_service.rb +++ b/app/services/merge_requests/squash_service.rb @@ -4,14 +4,12 @@ module MergeRequests class SquashService < MergeRequests::BaseService include Git::Logger - def idempotent? - true - end - def execute # If performing a squash would result in no change, then # immediately return a success message without performing a squash - return success(squash_sha: merge_request.diff_head_sha) if squash_redundant? + if merge_request.commits_count < 2 && message.nil? + return success(squash_sha: merge_request.diff_head_sha) + end if merge_request.squash_in_progress? return error(s_('MergeRequests|Squash task canceled: another squash is already in progress.')) @@ -22,12 +20,6 @@ module MergeRequests private - def squash_redundant? - return true if merge_request.merged? - - merge_request.commits_count < 2 && message.nil? - end - def squash! squash_sha = repository.squash(current_user, merge_request, message || merge_request.default_squash_commit_message) |