diff options
author | Sean McGivern <sean@gitlab.com> | 2017-07-07 17:09:29 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-07-07 17:34:33 +0300 |
commit | 4209b647f87d99b21aebcc9f311e8214c2658136 (patch) | |
tree | 994064741174944171682117411052716c9bd0ff /app/services/merge_requests | |
parent | d40445e4c9964ae0ab793bfdd7ba530de4259716 (diff) |
Don't mark empty MRs as merged on push to the target branch
When we push to an MR's target branch, we check if the MR's HEAD commit is
contained in the push. This lets us mark MRs as merged if they were merged
manually.
However, we also added a feature where you can create an empty MR from an
issue. If that MR is created around the time of a merge to the default branch,
we would process the push after creating the MR, and consider it to be a manual
merge.
To fix that, we exclude empty MRs from this process. If they are empty, they
were empty before the push we're processing, so we shouldn't touch them!
Diffstat (limited to 'app/services/merge_requests')
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index c5f959a1874..bc4a13cf4bc 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -35,11 +35,12 @@ module MergeRequests # target branch manually def close_merge_requests commit_ids = @commits.map(&:id) - merge_requests = @project.merge_requests.opened.where(target_branch: @branch_name).to_a + merge_requests = @project.merge_requests.preload(:merge_request_diff).opened.where(target_branch: @branch_name).to_a merge_requests = merge_requests.select(&:diff_head_commit) merge_requests = merge_requests.select do |merge_request| - commit_ids.include?(merge_request.diff_head_sha) + commit_ids.include?(merge_request.diff_head_sha) && + merge_request.merge_request_diff.state != 'empty' end filter_merge_requests(merge_requests).each do |merge_request| |