2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-25 14:38:07 +00:00
|
|
|
module Projects
|
|
|
|
class AfterImportService
|
2017-09-01 12:01:50 +00:00
|
|
|
RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join('refs', n, '/') }
|
2017-08-25 14:38:07 +00:00
|
|
|
|
|
|
|
def initialize(project)
|
|
|
|
@project = project
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
Projects::HousekeepingService.new(@project).execute do
|
2017-09-01 12:01:50 +00:00
|
|
|
repository.delete_all_refs_except(RESERVED_REF_PREFIXES)
|
2017-08-25 14:38:07 +00:00
|
|
|
end
|
|
|
|
rescue Projects::HousekeepingService::LeaseTaken => e
|
|
|
|
Rails.logger.info(
|
|
|
|
"Could not perform housekeeping for project #{@project.full_path} (#{@project.id}): #{e}")
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def repository
|
|
|
|
@repository ||= @project.repository
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|