fork分支PR

This commit is contained in:
huang 2016-08-04 18:30:04 +08:00
parent 5419103268
commit f4bda16469
3 changed files with 20 additions and 3 deletions

View File

@ -2,6 +2,7 @@ class PullRequestsController < ApplicationController
before_filter :find_project_and_repository before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new] before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new]
layout "base_projects" layout "base_projects"
include PullRequestsHelper
# 返回json格式 # 返回json格式
def index def index
@ -22,6 +23,16 @@ class PullRequestsController < ApplicationController
def new def new
@rev = @g.branches(@project.gpid).map{|b| b.name} @rev = @g.branches(@project.gpid).map{|b| b.name}
@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
end
# @forked_rev = @g.branches(forked_project.gpid).map{|b| b.name}
@target_project << "#{get_user_name(@project.user_id)}/#{@project.name}"
end end
# Creates a merge request. # Creates a merge request.
@ -45,6 +56,7 @@ class PullRequestsController < ApplicationController
description = params[:description] description = params[:description]
source_branch = params[:source_branch] source_branch = params[:source_branch]
target_branch = params[:target_branch] target_branch = params[:target_branch]
target_project = 1549
begin begin
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch) request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
respond_to do |format| respond_to do |format|

View File

@ -10,4 +10,8 @@ module PullRequestsHelper
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'') content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
end end
def get_user_name user_id
User.find(user_id).try(:login)
end
end end

View File

@ -13,12 +13,13 @@
<!--<select name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>rep_quality</option></select>--> <!--<select name="source_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>develop</option><option>rep_quality</option></select>-->
<div class="cl mb10"></div> <div class="cl mb10"></div>
<div class="merge-option-name fl" style="padding:5px 0">目标分支</div> <div class="merge-option-name fl" style="padding:5px 0">目标分支</div>
<%= select_tag :branch, options_for_select(@rev), :name => "target_branch", :value => "target_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetProject" %> <% unless @target_project.blank? %>
<%= select_tag :branch, options_for_select(@target_project), :name => "target_project", :value => "target_project", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetProject" %>
<% end %>
<%= select_tag :branch, options_for_select(@rev), :name => "target_branch", :value => "target_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %> <%= select_tag :branch, options_for_select(@rev), :name => "target_branch", :value => "target_branch", :class => "ml30 fontGrey3 fb fl", :style => "padding:5px 0 5px 5px;", :id => "targetBranch" %>
<!--<select name="target_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>hjq_course</option><option>hjq_beidou</option><option>develop</option><option>dev_huang</option></select>--> <!--<select name="target_branch" value="source_branch" class="ml30 fontGrey3 fb fl"><option>master</option><option>hjq_course</option><option>hjq_beidou</option><option>develop</option><option>dev_huang</option></select>-->
<div class="cl"></div> <div class="cl"></div>
<p class="fl ml100 mt10"><a href="javascript:void(0);" class="fr linkGrey2">修改分支</a></p>
<div class="cl"></div>
</div> </div>
<div class="new-merge-row b_grey" style="border-top:1px solid #ddd;"> <div class="new-merge-row b_grey" style="border-top:1px solid #ddd;">
<a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a> <a href="javascript:void(0);" class="BlueCirBtn fl ml10" onclick="pull_request_commit()">提交请求</a>