|
|
@ -473,6 +473,17 @@ class ShixunsController < ApplicationController
|
|
|
|
@shixun.shixun_service_configs.create!(config) if name.present?
|
|
|
|
@shixun.shixun_service_configs.create!(config) if name.present?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# 添加第二仓库
|
|
|
|
|
|
|
|
if params[:is_secret_repository]
|
|
|
|
|
|
|
|
add_secret_repositoy
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# 如果有仓库,就要删
|
|
|
|
|
|
|
|
if @shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
|
|
|
GitService.delete_repository(repo_path: @shixun.shixun_secret_repository.repo_path)
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.destroy
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
rescue Exception => e
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
uid_logger_error(e.message)
|
|
|
|
tip_exception("实训保存失败")
|
|
|
|
tip_exception("实训保存失败")
|
|
|
@ -819,6 +830,29 @@ class ShixunsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 设置私密版本库的在tpm中的目录
|
|
|
|
|
|
|
|
def set_secret_dir
|
|
|
|
|
|
|
|
raise("设置路径不能为空") if params[:secret_dir_path].blank?
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.update_attribute(:secret_dir_path, params[:secret_dir_path])
|
|
|
|
|
|
|
|
normal_status("设置成功")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def secret_repository
|
|
|
|
|
|
|
|
begin
|
|
|
|
|
|
|
|
@repo_path = @shixun.shixun_secret_repository&.repo_path
|
|
|
|
|
|
|
|
@repo_url = repo_url @repo_path
|
|
|
|
|
|
|
|
@trees = GitService.file_tree(repo_path: @repo_path, path: params[:path])
|
|
|
|
|
|
|
|
logger.info("#11@@#@#@#@111#@@@@###{@trees}")
|
|
|
|
|
|
|
|
if @trees
|
|
|
|
|
|
|
|
logger.info("#@@#@#@#@#@@@@###{@trees.try(:count)}")
|
|
|
|
|
|
|
|
@latest_commit = [GitService.commits(repo_path: @repo_path).first]
|
|
|
|
|
|
|
|
Rails.logger.info("########## #{@latest_commit}")
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
|
|
|
logger.error(e.message)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
include GitCommon
|
|
|
|
include GitCommon
|
|
|
|
|
|
|
|
|
|
|
|
def update_file
|
|
|
|
def update_file
|
|
|
@ -990,4 +1024,13 @@ private
|
|
|
|
modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1)
|
|
|
|
modify_shixun = ShixunModify.exists?(:myshixun_id => current_myshixun.id, :shixun_id => @shixun.id, :status => 1)
|
|
|
|
games.size != min_challenges.size || modify_shixun
|
|
|
|
games.size != min_challenges.size || modify_shixun
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 添加私密仓库
|
|
|
|
|
|
|
|
def add_secret_repositoy
|
|
|
|
|
|
|
|
# 防止跟tpm版本库重名,加了前缀secret
|
|
|
|
|
|
|
|
repo_path = repo_namespace(current_user.login, "secret_#{@shixun.identifier}")
|
|
|
|
|
|
|
|
GitService.add_repository(repo_path: repo_path)
|
|
|
|
|
|
|
|
@shixun.shixun_secret_repository.create!(repo_name: repo_path.split(".")[0])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|