forke项目发送pull request API

This commit is contained in:
huang 2016-08-04 19:32:44 +08:00
parent f4bda16469
commit ab6acb460e
2 changed files with 9 additions and 6 deletions

View File

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

View File

@ -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 %>
<div class="new-merge-wrap">
<div class="merge-option-name fl mt8">标题</div><input type="text" id="pr_name" name="title" class="merge-title-input fl ml30" />
<p id ="pull_request_title" class="fl ml100 fontGrey2 mt5 c_red" style="display: none">标题不能为空</p>