summaryrefslogtreecommitdiff
path: root/app/services
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2016-12-09 11:12:38 +0100
committerAdam Niedzielski <adamsunday@gmail.com>2016-12-09 12:10:26 +0100
commit9190cea21524f936c0ae8a9e754c861f13583fc5 (patch)
treed211f9276213d7db90d9a7e8f6482172d342b331 /app/services
parentaa0a7aa3b5ba59b772f4d0c0bd061d278295b01f (diff)
downloadgitlab-ce-9190cea21524f936c0ae8a9e754c861f13583fc5.tar.gz
Do not reload diff for merge request made from fork when target branch in fork is updateddo-not-refresh-main-when-fork-target-branch-updated
The target branch of a merge request has to be a branch in the project for which the merge request is submitted. When a branch changes in a fork, it does not make sense to reload diffs of merge requests in the upstream project that use the same branch name as the target branch. Please note that it does make sense to reload diffs when the source branch changes.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/merge_requests/refresh_service.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index e4056306bc4..0a9563ed7e7 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -55,8 +55,9 @@ module MergeRequests
# Refresh merge request diff if we push to source or target branch of merge request
# Note: we should update merge requests from forks too
def reload_merge_requests
- merge_requests = @project.merge_requests.opened.by_branch(@branch_name).to_a
- merge_requests += fork_merge_requests.by_branch(@branch_name).to_a
+ merge_requests = @project.merge_requests.opened.
+ by_source_or_target_branch(@branch_name).to_a
+ merge_requests += fork_merge_requests
merge_requests = filter_merge_requests(merge_requests)
merge_requests.each do |merge_request|
@@ -157,13 +158,14 @@ module MergeRequests
def merge_requests_for_source_branch
@source_merge_requests ||= begin
merge_requests = @project.origin_merge_requests.opened.where(source_branch: @branch_name).to_a
- merge_requests += fork_merge_requests.where(source_branch: @branch_name).to_a
+ merge_requests += fork_merge_requests
filter_merge_requests(merge_requests)
end
end
def fork_merge_requests
- @fork_merge_requests ||= @project.fork_merge_requests.opened
+ @fork_merge_requests ||= @project.fork_merge_requests.opened.
+ where(source_branch: @branch_name).to_a
end
def branch_added?