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,21 +361,22 @@ update
@repository.url = @repository.identifier
@repository.project_id = -1
ActiveRecord::Base.transaction do
begin
if request.post? && @repository.save
begin
s = Trustie::Gitlab::Sync.new
s.create_shixun(@shixun, @repository)
gproject = s.create_shixun(@shixun, @repository)
raise "sync failed" if @shixun.gpid.blank?
redirect_to(:controller => 'repositories', :action => 'shixun_show', :shixun_id => @shixun, :identifier => @repository.try(:identifier))
else
redirect_to settings_shixun_url(@shixun, :tab => 'repositories',:repository_error_message => @repository.errors.full_messages)
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
@shixun.update_attribute(:gpid, nil)
if @repository.id
@repository.destroy
end
end
else
respond_to do |format|
format.js{flash[:notice] = "版本库创建失败"}
end
end
end
elsif @project

View File

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

View File

@ -38,10 +38,6 @@
<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}" %>
</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? %>