[#399] smarter selection of target project for pull requests

This commit is contained in:
Alexander Machehin 2014-06-10 17:31:15 +06:00
parent 16fa446698
commit b20fa2bbc2
1 changed files with 5 additions and 2 deletions

View File

@ -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