Commit 9211b541 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Improve MR code reloading when push code

Every time you pushed to master it updates merge requests that has master
as target branch. So if you have 50 open merge requests point to master
it will reload all of them every time you push a single commit to
master. The funny thing is that after reloading diff of most merge
requests looks the same.

After this patch we update diff only if we push commit to master that
includes in MR commits list.

For example we have next repository:

feature: A - B - C
master: A

We create merge requests #1 with code from feature to master.

MR #1: B - C

If we push to master commit D - MR will not be reloaded. So picture will
look next:

feature: A - B - C
master: A - D
MR #1: B - C

And if we push to master commit B - MR will be reloaded. So picture will
look next:

feature: A - B - C
master: A - B
MR #1: C
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent bf393479
......@@ -43,8 +43,22 @@ module MergeRequests
merge_requests = filter_merge_requests(merge_requests)
merge_requests.each do |merge_request|
if merge_request.source_branch == @branch_name
merge_request.reload_code
merge_request.mark_as_unchecked
else
mr_commit_ids = merge_request.commits.map(&:id)
push_commit_ids = @commits.map(&:id)
matches = mr_commit_ids & push_commit_ids
if matches.any?
merge_request.reload_code
merge_request.mark_as_unchecked
else
merge_request.mark_as_unchecked
end
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment