diff options
author | Mark Chao <mchao@gitlab.com> | 2018-11-03 17:36:19 +0800 |
---|---|---|
committer | Mark Chao <mchao@gitlab.com> | 2018-12-07 19:24:34 +0800 |
commit | 1f7647f446c9659ec0a41e48433a711e95f0b153 (patch) | |
tree | 19fb693fd54d0b551c5dfcf64825b9e6b888fadd /app | |
parent | a89a73c1cc8576d75afc947cec14f19e1ae8a30d (diff) | |
download | gitlab-ce-1f7647f446c9659ec0a41e48433a711e95f0b153.tar.gz |
Update merge request's merge_commit for branch update
Analyze new commits graph to determine each commit's merge commit.
Fix "merged with [commit]" info for merge requests being merged
automatically by other actions.
Allow analyzing upto the relevant commit
Diffstat (limited to 'app')
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index 667b5916f38..91de910796b 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -58,13 +58,22 @@ module MergeRequests .preload(:latest_merge_request_diff) .where(target_branch: @push.branch_name).to_a .select(&:diff_head_commit) + .select do |merge_request| + commit_ids.include?(merge_request.diff_head_sha) && + merge_request.merge_request_diff.state != 'empty' + end + merge_requests = filter_merge_requests(merge_requests) - merge_requests = merge_requests.select do |merge_request| - commit_ids.include?(merge_request.diff_head_sha) && - merge_request.merge_request_diff.state != 'empty' - end + return if merge_requests.empty? + + analyzer = Gitlab::BranchPushMergeCommitAnalyzer.new( + @commits.reverse, + relevant_commit_ids: merge_requests.map(&:diff_head_sha) + ) + + merge_requests.each do |merge_request| + merge_request.merge_commit_sha = analyzer.get_merge_commit(merge_request.diff_head_sha) - filter_merge_requests(merge_requests).each do |merge_request| MergeRequests::PostMergeService .new(merge_request.target_project, @current_user) .execute(merge_request) |