diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 23bab6a58..41a4ced17 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -91,11 +91,20 @@ class GamesController < ApplicationController # git_repository_url @myshixun, "Myshixun" # @st 0 实践任务 1 选择题任务 def show - # g = Gitlab.client - # g_name = g.project(@myshixun.gpid).try(:name) - # if g_name.include?("-") - # g.delete_project() - # end + g = Gitlab.client + g_name = g.project(@myshixun.gpid).try(:name) + g_rep = @myshixun.repository + g_identifier = g_rep.try(:identifier) + if g_name.include?("-") || g_identifier.include?("-") + g_user_id = @myshixun.owner.try(:gid) + g_name = g_name.split("-") + g_project_name = g_name[0] + num = g_name[1] + g_id = g.current_user_project(g_user_id, g_project_name).first.try(:id) + sql = "update `repositories` set identifier='#{g_project_name}' where id=#{g_rep.id}" + ActiveRecord::Base.connection.execute(sql) + @myshixun.update_attribute(:gpid, g_id) + end # 展示全部实训 # git_myshixun_url_ip @myshixun, user_id @is_subject = params[:is_subject]