diff options
author | Stan Hu <stanhu@gmail.com> | 2018-10-25 23:04:03 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-10-30 02:51:22 +0300 |
commit | 0509c3cf17976a2acb53ea84a51b0f50d1f400fb (patch) | |
tree | 24130858287add307a940d172739d61bb4bfb0da /app/services | |
parent | 44a6b8d4f7feb8ba42981526379e8395fdd6f67e (diff) |
Fix extra merge request versions created from forked merge requests
When a forked merge request was created with the same branch name as the
target name, MergeRequests::RefreshService would always create a new
diff even though nothing had changed. For example, on GitLab.com:
1. There were a number of merge requests in the gitlab-ce and www-gitlab-com
projects that had old merge requests from the community.
2. These merge requests originated from forked projects and used the
source branch master.
3. When someone pushed to master in the main repository, MergeRequests::RefreshService
would see that master matched the merge requests in question and generated a new
diff.
4. This led to an explosion of merge request diffs and slowed down the "Changes"
tab considerably.
This change alters MergeRequests::RefreshService so that it will only
refresh the diff if the merge request's source project and branch
match. Otherwise, the refresh will only happen if a pushed commit
contains a commit relevant to the existing merge request.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/53153
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb index b03d14fa3cc..f01872b205e 100644 --- a/app/services/merge_requests/refresh_service.rb +++ b/app/services/merge_requests/refresh_service.rb @@ -85,7 +85,7 @@ module MergeRequests .where.not(target_project: @project).to_a filter_merge_requests(merge_requests).each do |merge_request| - if merge_request.source_branch == @push.branch_name || @push.force_push? + if branch_and_project_match?(merge_request) || @push.force_push? merge_request.reload_diff(current_user) else mr_commit_ids = merge_request.commit_shas @@ -104,6 +104,11 @@ module MergeRequests end # rubocop: enable CodeReuse/ActiveRecord + def branch_and_project_match?(merge_request) + merge_request.source_project == @project && + merge_request.source_branch == @push.branch_name + end + def reset_merge_when_pipeline_succeeds merge_requests_for_source_branch.each(&:reset_merge_when_pipeline_succeeds) end |