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:
- There were a number of merge requests in the
gitlab-ce
andwww-gitlab-com
projects that had old merge requests from the community. - These merge requests originated from forked projects and used the source branch
master
. - When someone pushed to
master
in the main repository,MergeRequests::RefreshService
would see thatmaster
matched the merge requests in question and generated a new diff. - 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.
Edited by Stan Hu