|
|
|
@ -53,7 +53,8 @@ class WelcomeController < ApplicationController
|
|
|
|
|
local_shixun = LocalShixun.create!(name: shixun.name, description: shixun.description, user_id: User.current.id, status: 0,
|
|
|
|
|
trainee: shixun.trainee, webssh: shixun.webssh, multi_webssh: shixun.multi_webssh,
|
|
|
|
|
can_copy: shixun.can_copy, identifier: generate_identifier, shixun_id: shixun.id,
|
|
|
|
|
use_scope: shixun.use_scope, visits: 1, evaluate_script: shixun.evaluate_script)
|
|
|
|
|
use_scope: shixun.use_scope, visits: 1, evaluate_script: shixun.evaluate_script,
|
|
|
|
|
local_giturl: shixun.git_url)
|
|
|
|
|
|
|
|
|
|
# 同步镜像
|
|
|
|
|
if shixun.mirror_repositories.present?
|
|
|
|
@ -97,10 +98,10 @@ class WelcomeController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
render :json => {status: 0, message: "同步成功"}
|
|
|
|
|
render :json => {status: 0, message: "success"}
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
logger.error("shixun_local_in ##{e.message}")
|
|
|
|
|
render :json => {status: -1, message: "同步失败,#{e.message}"}
|
|
|
|
|
render :json => {status: -1, message: "error,#{e.message}"}
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -147,6 +148,14 @@ class WelcomeController < ApplicationController
|
|
|
|
|
raise "版本库创建失败" if shixun.gpid.blank? # 若和gitlab没同步成功,则抛出异常
|
|
|
|
|
g = Gitlab.client
|
|
|
|
|
shixun.update_column(:git_url, g.project(shixun.gpid).path_with_namespace)
|
|
|
|
|
local_git_path = local_shixun.local_giturl.split('/').last if local_shixun.local_giturl.present?
|
|
|
|
|
new_giturl = "http://educoder:xinhu1ji2qu3@"+g.project(shixun.gpid).http_url_to_repo.split('//').last
|
|
|
|
|
system("cd tmp/repositories/#{local_git_path}")
|
|
|
|
|
system("git remote remove origin")
|
|
|
|
|
system("git remote add origin #{new_giturl}")
|
|
|
|
|
system("git add .")
|
|
|
|
|
system("git commit -m 'first commit'")
|
|
|
|
|
system("git push origin master")
|
|
|
|
|
|
|
|
|
|
# 同步关卡信息
|
|
|
|
|
local_challenges = LocalChallenge.where(local_shixun_id: local_shixun.id)
|
|
|
|
|