|
|
|
@ -232,10 +232,12 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 同步私密版本库
|
|
|
|
|
if @shixun.shixun_secret_repository
|
|
|
|
|
repo_name = "#{current_user.login}/secret_#{@shixun.identifier}"
|
|
|
|
|
# 源仓库的的私密版本库地址
|
|
|
|
|
repo_name = @shixun.shixun_secret_repository.repo_name
|
|
|
|
|
# 新生成的地址
|
|
|
|
|
fork_repository_name = "#{current_user.login}/secret_#{@new_shixun.identifier}"
|
|
|
|
|
ShixunSecretRepository.create!(shixun_id: @new_shixun.id,
|
|
|
|
|
repo_name: "#{repo_name}",
|
|
|
|
|
repo_name: "#{fork_repository_name}",
|
|
|
|
|
secret_dir_path: @shixun.shixun_secret_repository.secret_dir_path)
|
|
|
|
|
GitService.fork_repository(repo_path: "#{repo_name}.git", fork_repository_path: (fork_repository_name + ".git"))
|
|
|
|
|
end
|
|
|
|
@ -335,7 +337,10 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger_error("copy shixun failed ##{e.message}")
|
|
|
|
|
g.delete_project(gshixungshixun.id) if gshixun.try(:id).present? # 异常后,如果已经创建了版本库需要删除该版本库
|
|
|
|
|
# 删除版本库
|
|
|
|
|
# 删除私密版本库
|
|
|
|
|
GitService.delete_repository(repo_path: "#{fork_repository_name}.git") if @new_shixun.shixun_secret_repository&.repo_name
|
|
|
|
|
GitService.delete_repository(repo_path: @new_shixun.repo_path) if @new_shixun.repo_path
|
|
|
|
|
tip_exception("实训Fork失败")
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
end
|
|
|
|
|