From 50653d1eb9a2fd22494c5ffed96200231a7b34bc Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 13 Oct 2017 21:01:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=89=88=E6=9C=AC=E5=BA=93?= =?UTF-8?q?=E7=A9=BA=E7=99=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) 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]