From 59ac0924da8ffc6ae28eecffda2654cd7ab8f761 Mon Sep 17 00:00:00 2001 From: Paul Slaughter Date: Fri, 5 Apr 2019 07:29:53 +0000 Subject: Fix IDE detecting MR from fork branch **Why?** Currently the IDE loads a merge request based on only the `source_branch` name. This means it loads MR's from forks that have the same branch name (not good). - This required updating the BE API to accept `source_project_id` --- app/finders/merge_requests_finder.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'app/finders') diff --git a/app/finders/merge_requests_finder.rb b/app/finders/merge_requests_finder.rb index 84689ff5dc7..29947bc94d5 100644 --- a/app/finders/merge_requests_finder.rb +++ b/app/finders/merge_requests_finder.rb @@ -40,7 +40,8 @@ class MergeRequestsFinder < IssuableFinder items = by_commit(super) items = by_source_branch(items) items = by_wip(items) - by_target_branch(items) + items = by_target_branch(items) + by_source_project_id(items) end private @@ -74,6 +75,16 @@ class MergeRequestsFinder < IssuableFinder items.where(target_branch: target_branch) end + def source_project_id + @source_project_id ||= params[:source_project_id].presence + end + + def by_source_project_id(items) + return items unless source_project_id + + items.where(source_project_id: source_project_id) + end + def by_wip(items) if params[:wip] == 'yes' items.where(wip_match(items.arel_table)) -- cgit v1.2.1