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

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

View File

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