shixun模块版本库创建事务一致性处理

This commit is contained in:
huang 2017-03-13 14:12:34 +08:00
parent fbc52a7892
commit 0298c45b20
3 changed files with 15 additions and 18 deletions

View File

@ -361,22 +361,23 @@ update
@repository.url = @repository.identifier @repository.url = @repository.identifier
@repository.project_id = -1 @repository.project_id = -1
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
begin
if request.post? && @repository.save if request.post? && @repository.save
s = Trustie::Gitlab::Sync.new begin
s.create_shixun(@shixun, @repository) s = Trustie::Gitlab::Sync.new
raise "sync failed" if @shixun.gpid.blank? gproject = s.create_shixun(@shixun, @repository)
redirect_to(:controller => 'repositories', :action => 'shixun_show', :shixun_id => @shixun, :identifier => @repository.try(:identifier)) raise "sync failed" if @shixun.gpid.blank?
redirect_to(:controller => 'repositories', :action => 'shixun_show', :shixun_id => @shixun, :identifier => @repository.try(:identifier))
rescue Exception => e
@shixun.update_attribute(:gpid, nil)
if @repository.id
@repository.destroy
end
end
else else
redirect_to settings_shixun_url(@shixun, :tab => 'repositories',:repository_error_message => @repository.errors.full_messages) respond_to do |format|
format.js{flash[:notice] = "版本库创建失败"}
end
end end
rescue Gitlab::Error::Forbidden => e
@message = l(:label_pull_request_forbidden)
rescue Gitlab::Error::NotFound => e
@message = l(:label_pull_request_notfound)
rescue Exception => e
puts e
end
end end
elsif @project elsif @project
# 判断版本库创建者是否有同名版本库,避免版本库路径一致问题 # 判断版本库创建者是否有同名版本库,避免版本库路径一致问题

View File

@ -58,7 +58,7 @@
function project_repository_commit() function project_repository_commit()
{ {
if(regex_repoistory_name()) // if(regex_repoistory_name())
{ {
$("#new_repository").submit(); $("#new_repository").submit();
} }

View File

@ -38,10 +38,6 @@
<li id="project_menu_011"> <li id="project_menu_011">
<%= link_to 1 > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k 99999}</span>".html_safe : "#{l(:project_module_training_tasks)}", shixun_challenges_url(@shixun), :class => "pro_new_proname", :title => "#{99999}" %> <%= link_to 1 > 0 ? "#{l(:project_module_training_tasks)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k 99999}</span>".html_safe : "#{l(:project_module_training_tasks)}", shixun_challenges_url(@shixun), :class => "pro_new_proname", :title => "#{99999}" %>
</li> </li>
<!--讨论区-->
<li id="project_menu_03">
<%= link_to 1 > 0 ? "#{l(:project_module_boards)}<span class='issues_nav_tag ml5'>#{switch_integer_into_k 99999}</span>".html_safe : "#{l(:project_module_boards)}", project_boards_path(@shixun), :class => "pro_new_proname", :title => "#{99999}" %>
</li>
<!--版本库--> <!--版本库-->
<% unless @shixun.repository.nil? %> <% unless @shixun.repository.nil? %>