fork成功不跳转提示

This commit is contained in:
huang 2016-08-05 15:23:52 +08:00
parent 308b050612
commit 43a4e0a2bf
2 changed files with 12 additions and 7 deletions

View File

@ -1,3 +1,4 @@
class PullRequestsController < ApplicationController 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]
@ -61,13 +62,15 @@ class PullRequestsController < ApplicationController
begin begin
# 如果传送了目标项目ID则PR请求发至目标项目 # 如果传送了目标项目ID则PR请求发至目标项目
if params[:forked_project_id] && params[:source_project] == "forked_project_name" if params[:forked_project_id] && params[:source_project] == "forked_project_name"
target_project_id = params[:target_project_id] target_project_id = params[:forked_project_id].to_i
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) 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)
@fork_project_name = Project.find(@project.forked_from_project_id).try(:name)
@fork_pr_message = true if @fork_project_name
else else
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)
end respond_to do |format|
respond_to do |format| format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)} end
end end
rescue Exception => e rescue Exception => e
@message = e.message @message = e.message

View File

@ -1,5 +1,7 @@
<% if @message %> <% if @message %>
<div class="flash error"> <div class="flash error"><%= @message %></div>
<%= @message %> <% end %>
</div>
<% if @fork_pr_message %>
<div class="flash notice">您的Pull Request请求已成功发送至源项目<%= @fork_project_name %></div>
<% end %> <% end %>