|  |  |  | @ -205,88 +205,7 @@ class WelcomeController < ApplicationController | 
			
		
	
		
			
				
					|  |  |  |  |     ActiveRecord::Base.transaction do | 
			
		
	
		
			
				
					|  |  |  |  |       shixun_list = [] | 
			
		
	
		
			
				
					|  |  |  |  |       LocalShixun.find_each do |local_shixun| | 
			
		
	
		
			
				
					|  |  |  |  |         identifier = generate_identifier | 
			
		
	
		
			
				
					|  |  |  |  |         shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id, | 
			
		
	
		
			
				
					|  |  |  |  |                                 trainee: local_shixun.trainee, webssh: local_shixun.webssh, multi_webssh: local_shixun.multi_webssh, | 
			
		
	
		
			
				
					|  |  |  |  |                                 can_copy: local_shixun.can_copy, identifier: identifier, reset_time: Time.now, | 
			
		
	
		
			
				
					|  |  |  |  |                                 modify_time: Time.now, use_scope: local_shixun.use_scope, visits: 1, evaluate_script: local_shixun.evaluate_script) | 
			
		
	
		
			
				
					|  |  |  |  |         m = ShixunMember.new(:user_id => User.current.id, :role => 1) | 
			
		
	
		
			
				
					|  |  |  |  |         shixun.shixun_members << m | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         # 同步镜像 | 
			
		
	
		
			
				
					|  |  |  |  |         local_mirrors = LocalMirrorRepository.where(local_shixun_id: local_shixun.id) | 
			
		
	
		
			
				
					|  |  |  |  |         if local_mirrors.present? | 
			
		
	
		
			
				
					|  |  |  |  |           local_mirrors.each do |local_mirror| | 
			
		
	
		
			
				
					|  |  |  |  |             local_mirror_new = MirrorRepository.where(type_name: local_mirror.try(:type_name)).first | 
			
		
	
		
			
				
					|  |  |  |  |             ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => local_mirror_new.id) | 
			
		
	
		
			
				
					|  |  |  |  |           end | 
			
		
	
		
			
				
					|  |  |  |  |         end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         # 同步技术标签 | 
			
		
	
		
			
				
					|  |  |  |  |         local_shixun_tags = LocalShixunTagRepertoire.where(local_shixun_id: local_shixun.id) | 
			
		
	
		
			
				
					|  |  |  |  |         if local_shixun_tags.present? | 
			
		
	
		
			
				
					|  |  |  |  |           local_shixun_tags.each do |str| | 
			
		
	
		
			
				
					|  |  |  |  |             ShixunTagRepertoire.create!(:tag_repertoire_id => str.tag_repertoire_id, :shixun_id => shixun.id) | 
			
		
	
		
			
				
					|  |  |  |  |           end | 
			
		
	
		
			
				
					|  |  |  |  |         end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         # 创建版本库 | 
			
		
	
		
			
				
					|  |  |  |  |         repository = Repository.new | 
			
		
	
		
			
				
					|  |  |  |  |         repository.shixun = shixun | 
			
		
	
		
			
				
					|  |  |  |  |         repository.type = 'Repository::Gitlab' | 
			
		
	
		
			
				
					|  |  |  |  |         repository.identifier = shixun.identifier.downcase | 
			
		
	
		
			
				
					|  |  |  |  |         repository.project_id = -1 | 
			
		
	
		
			
				
					|  |  |  |  |         repository.save! | 
			
		
	
		
			
				
					|  |  |  |  |         s = Trustie::Gitlab::Sync.new | 
			
		
	
		
			
				
					|  |  |  |  |         s.create_shixun(shixun, repository) | 
			
		
	
		
			
				
					|  |  |  |  |         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 | 
			
		
	
		
			
				
					|  |  |  |  |         # 如果有目录才执行 | 
			
		
	
		
			
				
					|  |  |  |  | 	logger.info("##########_------------- path: #{File.directory?("/home/pdl/trustie24/tmp/repositories/local/#{local_git_path}")}") | 
			
		
	
		
			
				
					|  |  |  |  | 	logger.info("##########_------------- new_giturl: #{new_giturl}") | 
			
		
	
		
			
				
					|  |  |  |  |         if File.directory?("/home/pdl/trustie24/tmp/repositories/local/#{local_git_path}") | 
			
		
	
		
			
				
					|  |  |  |  | 	  logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@-----daole") | 
			
		
	
		
			
				
					|  |  |  |  |           system("cd /home/pdl/trustie24/tmp/repositories/local/#{local_git_path};git remote remove origin;git remote add origin #{new_giturl}; | 
			
		
	
		
			
				
					|  |  |  |  |                   git add .;git commit -m '..';git push origin master") | 
			
		
	
		
			
				
					|  |  |  |  |           logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!over") | 
			
		
	
		
			
				
					|  |  |  |  |         end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         #  http://Hjqreturn:xinhu1ji2qu3@bdgit.educoder.net/Hjqreturn/pgfqe6ch8.git (fetch) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |         # 同步关卡信息 | 
			
		
	
		
			
				
					|  |  |  |  |         local_challenges = LocalChallenge.where(local_shixun_id: local_shixun.id) | 
			
		
	
		
			
				
					|  |  |  |  |         if local_challenges.present? | 
			
		
	
		
			
				
					|  |  |  |  |           local_challenges.each do |local_challenge| | 
			
		
	
		
			
				
					|  |  |  |  |             new_challenge = Challenge.new | 
			
		
	
		
			
				
					|  |  |  |  |             new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id", "test_set_score") | 
			
		
	
		
			
				
					|  |  |  |  |             new_challenge.user_id = User.current.id | 
			
		
	
		
			
				
					|  |  |  |  |             new_challenge.shixun_id = shixun.id | 
			
		
	
		
			
				
					|  |  |  |  |             new_challenge.save! | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             # 同步测试集 | 
			
		
	
		
			
				
					|  |  |  |  |             local_test_sets = LocalTestSet.where(local_challenge_id: local_challenge.id) | 
			
		
	
		
			
				
					|  |  |  |  |             if local_test_sets.present? | 
			
		
	
		
			
				
					|  |  |  |  |               local_test_sets.each do |local_test_set| | 
			
		
	
		
			
				
					|  |  |  |  |                 new_test_set = TestSet.new | 
			
		
	
		
			
				
					|  |  |  |  |                 new_test_set.attributes = local_test_set.attributes.dup.except("id","challenge_id") | 
			
		
	
		
			
				
					|  |  |  |  |                 new_test_set.challenge_id = new_challenge.id | 
			
		
	
		
			
				
					|  |  |  |  |                 new_test_set.save! | 
			
		
	
		
			
				
					|  |  |  |  |               end | 
			
		
	
		
			
				
					|  |  |  |  |             end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |             # 同步关卡标签 | 
			
		
	
		
			
				
					|  |  |  |  |             local_challenge_tags = LocalChallengeTag.where(local_challenge_id: local_challenge.id) | 
			
		
	
		
			
				
					|  |  |  |  |             if local_challenge_tags.present? | 
			
		
	
		
			
				
					|  |  |  |  |               local_challenge_tags.each do |local_challenge_tag| | 
			
		
	
		
			
				
					|  |  |  |  |                 ChallengeTag.create!(:challenge_id => new_challenge.id, :name => local_challenge_tag.try(:name)) | 
			
		
	
		
			
				
					|  |  |  |  |               end | 
			
		
	
		
			
				
					|  |  |  |  |             end | 
			
		
	
		
			
				
					|  |  |  |  |           end | 
			
		
	
		
			
				
					|  |  |  |  |         end | 
			
		
	
		
			
				
					|  |  |  |  |         shixun = _local_to_shixun(local_shixun) | 
			
		
	
		
			
				
					|  |  |  |  |         shixun_list << shixun.identifier | 
			
		
	
		
			
				
					|  |  |  |  |       end | 
			
		
	
		
			
				
					|  |  |  |  |       render :json => {status: 0, message: "success", identifier: shixun_list} | 
			
		
	
	
		
			
				
					|  |  |  | @ -666,7 +585,7 @@ class WelcomeController < ApplicationController | 
			
		
	
		
			
				
					|  |  |  |  |     if local_mirrors.present? | 
			
		
	
		
			
				
					|  |  |  |  |       local_mirrors.each do |local_mirror| | 
			
		
	
		
			
				
					|  |  |  |  |         local_mirror_new = MirrorRepository.where(type_name: local_mirror.try(:type_name)).first | 
			
		
	
		
			
				
					|  |  |  |  |         ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => local_mirror_new.try(:id)) | 
			
		
	
		
			
				
					|  |  |  |  |         ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => local_mirror_new.id) | 
			
		
	
		
			
				
					|  |  |  |  |       end | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | @ -693,9 +612,13 @@ class WelcomeController < ApplicationController | 
			
		
	
		
			
				
					|  |  |  |  |     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 | 
			
		
	
		
			
				
					|  |  |  |  |     # 如果有目录才执行 | 
			
		
	
		
			
				
					|  |  |  |  |     if system("cd tmp/repositories/#{local_git_path}") | 
			
		
	
		
			
				
					|  |  |  |  |       system("cd tmp/repositories/#{local_git_path};git remote remove origin;git remote add origin #{new_giturl}; | 
			
		
	
		
			
				
					|  |  |  |  |     logger.info("##########_------------- path: #{File.directory?("/home/pdl/trustie24/tmp/repositories/local/#{local_git_path}")}") | 
			
		
	
		
			
				
					|  |  |  |  |     logger.info("##########_------------- new_giturl: #{new_giturl}") | 
			
		
	
		
			
				
					|  |  |  |  |     if File.directory?("/home/pdl/trustie24/tmp/repositories/local/#{local_git_path}") | 
			
		
	
		
			
				
					|  |  |  |  |       logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@-----daole") | 
			
		
	
		
			
				
					|  |  |  |  |       system("cd /home/pdl/trustie24/tmp/repositories/local/#{local_git_path};git remote remove origin;git remote add origin #{new_giturl}; | 
			
		
	
		
			
				
					|  |  |  |  |                   git add .;git commit -m '..';git push origin master") | 
			
		
	
		
			
				
					|  |  |  |  |       logger.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!over") | 
			
		
	
		
			
				
					|  |  |  |  |     end | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |