gitlab-org--gitlab-foss/app/services/projects/after_import_service.rb
Stan Hu 36b1a2d7d0 Don't run full gc in AfterImportService
Pull mirrors would run the `Projects::AfterImportService`, which would
force a `git gc` each time it finished. This is overkill and not
necessary now that we have refs packed more frequently
(https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/27826).

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/11556
2019-05-10 06:55:53 -05:00

26 lines
670 B
Ruby

# frozen_string_literal: true
module Projects
class AfterImportService
RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join('refs', n, '/') }
def initialize(project)
@project = project
end
def execute
Projects::HousekeepingService.new(@project).execute do
repository.delete_all_refs_except(RESERVED_REF_PREFIXES)
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