Merge pull request #400 from abf/rosa-build:399-smarter_selection_target_project
Smarter selection of target project for pull requests
This commit is contained in:
commit
d9c3d664f8
|
@ -121,7 +121,10 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
def autocomplete_to_project
|
def autocomplete_to_project
|
||||||
items = []
|
items = []
|
||||||
term = params[:term].to_s.strip.downcase
|
term = params[:term].to_s.strip.downcase
|
||||||
[Project.accessible_by(current_ability, :membered), @project.ancestors].each do |p|
|
[ Project.where(@project.pull_requests.last.try(:to_project)),
|
||||||
|
@project.ancestors,
|
||||||
|
Project.accessible_by(current_ability, :membered)
|
||||||
|
].each do |p|
|
||||||
items.concat p.by_owner_and_name(term)
|
items.concat p.by_owner_and_name(term)
|
||||||
end
|
end
|
||||||
items = items.uniq{|i| i.id}.select{|e| e.repo.branches.count > 0}
|
items = items.uniq{|i| i.id}.select{|e| e.repo.branches.count > 0}
|
||||||
|
@ -154,7 +157,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
||||||
def find_destination_project bang=true
|
def find_destination_project bang=true
|
||||||
project = Project.find_by_owner_and_name params[:to_project]
|
project = Project.find_by_owner_and_name params[:to_project]
|
||||||
raise ActiveRecord::RecordNotFound if bang && !project
|
raise ActiveRecord::RecordNotFound if bang && !project
|
||||||
project || @project
|
project || @project.pull_requests.last.try(:to_project) || @project.root
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_attrs
|
def set_attrs
|
||||||
|
|
Loading…
Reference in New Issue