diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 880fa89c6..8e119b19c 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -26,9 +26,7 @@ class PullRequestsController < ApplicationController @target_project = [] if @project.forked_from_project_id @forked_project = Project.find(@project.forked_from_project_id) - unless @forked_project.blank? - @target_project << "#{get_user_name(@forked_project.user_id)}/#{@forked_project.name}" - end + @target_project << "#{get_user_name(@forked_project.user_id)}/#{@forked_project.name}" end # @forked_rev = @g.branches(forked_project.gpid).map{|b| b.name} @target_project << "#{get_user_name(@project.user_id)}/#{@project.name}" @@ -56,9 +54,14 @@ class PullRequestsController < ApplicationController description = params[:description] source_branch = params[:source_branch] target_branch = params[:target_branch] - target_project = 1549 begin - request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) + # 如果传送了目标项目ID,则PR请求发至目标项目 + if params[:target_project_id] + target_project_id = params[:target_project_id] + request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) + else + request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) + end respond_to do |format| format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end diff --git a/app/views/pull_requests/_form.html.erb b/app/views/pull_requests/_form.html.erb index 299f4fac0..9b44fa943 100644 --- a/app/views/pull_requests/_form.html.erb +++ b/app/views/pull_requests/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id), :id => 'pull_request_form', :method => "post", :remote => true) do %> +<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create', :project_id => @project.id, :forked_project_id => @forked_project.try(:gpid)), :id => 'pull_request_form', :method => "post", :remote => true) do %>