GitLab steht aufgrund wichtiger Wartungsarbeiten am Montag, den 8. März, zwischen 17:00 und 19:00 Uhr nicht zur Verfügung.

after_import_service.rb 670 Bytes
Newer Older
1 2
# frozen_string_literal: true

Lin Jen-Shin's avatar
Lin Jen-Shin committed
3 4
module Projects
  class AfterImportService
5
    RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join('refs', n, '/') }
Lin Jen-Shin's avatar
Lin Jen-Shin committed
6 7 8 9 10 11 12

    def initialize(project)
      @project = project
    end

    def execute
      Projects::HousekeepingService.new(@project).execute do
13
        repository.delete_all_refs_except(RESERVED_REF_PREFIXES)
Lin Jen-Shin's avatar
Lin Jen-Shin committed
14 15 16 17 18 19 20 21 22 23 24 25 26
      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