diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-09 14:22:08 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2016-12-09 14:22:08 +0000 |
commit | cd83db4c2d00267127c9852ed8996d79fe954042 (patch) | |
tree | 7daf7ea7bede386c15654a4f11416f3feff8f2b3 /app | |
parent | 192d40e53e3a3bdd397b15f50d6ad1b9840c67b3 (diff) | |
parent | 9190cea21524f936c0ae8a9e754c861f13583fc5 (diff) | |
download | gitlab-ce-cd83db4c2d00267127c9852ed8996d79fe954042.tar.gz |
Merge branch 'do-not-refresh-main-when-fork-target-branch-updated' into 'master'
Do not reload diff for merge request made from fork when target branch in fork is updated
Closes #25263
See merge request !7973
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request.rb | 4 | ||||
-rw-r--r-- | app/services/merge_requests/refresh_service.rb | 10 |
2 files changed, 9 insertions, 5 deletions
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index dd9f1a7c85b..ea3cf1cdaac 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -101,7 +101,9 @@ class MergeRequest < ActiveRecord::Base validate :validate_branches, unless: [:allow_broken, :importing?, :closed_without_fork?] validate :validate_fork, unless: :closed_without_fork? - scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } + scope :by_source_or_target_branch, ->(branch_name) do + where("source_branch = :branch OR target_branch = :branch", branch: branch_name) + end scope :cared, ->(user) { where('assignee_id = :user OR author_id = :user', user: user.id) } scope :by_milestone, ->(milestone) { where(milestone_id: milestone) } scope :of_projects, ->(ids) { where(target_project_id: ids) } 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? |