<commit_before>module Travis
  module Worker
    module Job
      # Carries out task of cloning or synchronizing Git repositories and setting up the stage
      # for build to run on (for example, installing dependencies using Bundler, cleanin up build
      # artifacts and so on).
      #
      # ### Key methods
      #
      # * #checkout
      # * #install
      #
      # @see Travis::Job::Base
      class Repository

        #
        # Behaviors
        #

        include Shell

        autoload :Config, 'travis/worker/job/repository/config'

        #
        # API
        #

        attr_reader :dir
        attr_reader :slug
        attr_reader :config

        # @api public
        def initialize(dir, slug, config)
          @dir    = dir
          @slug   = slug
          @config = Config.new(config)
        end

        # @api public
        def checkout(commit = nil)
          exists? ? fetch : clone
          exec "git checkout -qf #{commit}" if commit
        end

        # @api public
        def install
          install? ? exec("bundle install #{config['bundler_args']}".strip) : true
        end


        # @api plugin
        def raw_url
          "https://raw.github.com/#{slug}"
        end

        #
        # Implementation
        #

        protected

          # @api plugin
          def clone
            exec 'export GIT_ASKPASS=echo', :echo => false # this makes git interactive auth fail
            exec "mkdir -p #{dir}", :echo => false
            exec "git clone --quiet #{source} #{dir}"
          end

          # @api plugin
          def fetch
            exec 'git clean -fdx'
            exec 'git fetch'
          end

          # @api plugin
          def exists?
            exec "test -d .git", :echo => false
          end

          # @api plugin
          def install?
            config.gemfile?
          end

          # @api plugin
          def source
            "git://github.com/#{slug}.git"
          end
      end # Repository
    end # Job
  end # Worker
end # Travis<commit_msg>Use --depth when we clone a git repo<commit_after>module Travis
  module Worker
    module Job
      # Carries out task of cloning or synchronizing Git repositories and setting up the stage
      # for build to run on (for example, installing dependencies using Bundler, cleanin up build
      # artifacts and so on).
      #
      # ### Key methods
      #
      # * #checkout
      # * #install
      #
      # @see Travis::Job::Base
      class Repository

        #
        # Behaviors
        #

        include Shell

        autoload :Config, 'travis/worker/job/repository/config'

        #
        # API
        #

        attr_reader :dir
        attr_reader :slug
        attr_reader :config

        # @api public
        def initialize(dir, slug, config)
          @dir    = dir
          @slug   = slug
          @config = Config.new(config)
        end

        # @api public
        def checkout(commit = nil)
          exists? ? fetch : clone
          exec "git checkout -qf #{commit}" if commit
        end

        # @api public
        def install
          install? ? exec("bundle install #{config['bundler_args']}".strip) : true
        end


        # @api plugin
        def raw_url
          "https://raw.github.com/#{slug}"
        end

        #
        # Implementation
        #

        protected

          # @api plugin
          def clone
            exec 'export GIT_ASKPASS=echo', :echo => false # this makes git interactive auth fail
            exec "mkdir -p #{dir}", :echo => false
            exec "git clone --depth=1000 --quiet #{source} #{dir}"
          end

          # @api plugin
          def fetch
            exec 'git clean -fdx'
            exec 'git fetch'
          end

          # @api plugin
          def exists?
            exec "test -d .git", :echo => false
          end

          # @api plugin
          def install?
            config.gemfile?
          end

          # @api plugin
          def source
            "git://github.com/#{slug}.git"
          end
      end # Repository
    end # Job
  end # Worker
end # Travis
{'fraction_non_alphanumeric': 0.08755426917510854, 'fraction_numerical': 0.000964785335262904, 'mean_word_length': 1.323249299719888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4721025', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1090, 'n_words': 361}