forked from Trustie/forgeplus
24 lines
867 B
Ruby
24 lines
867 B
Ruby
class TouchSyncJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(touchable)
|
|
puts "aaaa"
|
|
case touchable.class.to_s
|
|
when 'SyncRepositories::Github' || 'SyncRepositories::Gitee'
|
|
Reposync::SyncRepoService.call(touchable.repo_name)
|
|
when 'SyncRepositoryBranch'
|
|
sync_repository = touchable.sync_repository
|
|
result = []
|
|
if sync_repository.sync_direction == 1
|
|
result = Reposync::SyncBranchService.call(sync_repository.repo_name, touchable.gitlink_branch_name, sync_repository.sync_direction)
|
|
else
|
|
result = Reposync::SyncBranchService.call(sync_repository.repo_name, touchable.external_branch_name, sync_repository.sync_direction)
|
|
end
|
|
if result.is_a?(Array)
|
|
touchable.update_column(:sync_status, 1)
|
|
else
|
|
touchable.update_column(:sync_status, 2)
|
|
end
|
|
end
|
|
end
|
|
end |