创建项目上链后的操作已完成

This commit is contained in:
sylor_huang@126.com 2020-05-13 14:19:14 +08:00
parent 1c73e982ba
commit eec28fa054
2 changed files with 6 additions and 19 deletions

View File

@ -2,35 +2,26 @@ class ProjectCreateChainJob < ApplicationJob
queue_as :default
def perform(chain_params)
Rails.logger.info("########_response_chain_params_22222_#{chain_params}__")
status = 0
status = false
chain_type = chain_params[:type].to_s
reponame = chain_params[:reponame]
Rails.logger.info("########_response_chain_chain_type_#{chain_type}__")
Rails.logger.info("########_response_reponame_#{reponame}__")
5.times do |i|
if status == 200
if status
Rails.logger.info("########_repository__#{reponame}______create_chain_success__try:_#{i+1}_")
break
else
Rails.logger.info("########_repository__#{reponame}______start_to_create_chain__try:_#{i+1}_")
if chain_type == "create"
chain_status = create_chain(chain_params)
status = create_chain(chain_params)
elsif chain_type == "push"
chain_status = push_chain(chain_params)
else
chain_status = {status: 200}
status = push_chain(chain_params)
end
Rails.logger.info("########_response__chain_status__#{chain_status}__")
status = chain_status[:status].to_i
end
end
unless status == 200
Rails.logger.info("########_repository__#{reponame}__create_chain:___#{chain_status}____failed_to_create_chain__")
unless status
Rails.logger.info("########_repository__#{reponame}__create_chain:___#{status}____failed_to_create_chain__")
end
end
@ -38,8 +29,6 @@ class ProjectCreateChainJob < ApplicationJob
#创建项目的上链操作
def create_chain(chain_params)
Rails.logger.info("########_chain trustieCreate___#{chain_params[:ownername]}____#{chain_params[:reponame]}___")
system("chain trustieCreate #{chain_params[:ownername]} #{chain_params[:reponame]}")
end

View File

@ -31,8 +31,6 @@ class Repositories::CreateService < ApplicationService
ownername: user.try(:login),
reponame: @repository.try(:id)
}
Rails.logger.info("########_response_chain_params_111111_#{chain_params}__")
ProjectCreateChainJob.perform_later(chain_params) #创建上链操作
#暂时gitea的hook功能未完善
#Gitea::Repository::Hooks::CreateService.new(user, @repository.try(:identifier), hook_params).call #创建gitea的hook功能