<commit_before>require 'engineyard/error'

module EY
  class DeployConfig
    class Ref

      def initialize(cli_opts, env_config, repo)
        @cli_opts  = cli_opts
        @default   = env_config.branch
        @repo      = repo
        @force_ref = @cli_opts.fetch('force_ref', false)

        if @force_ref.kind_of?(String)
          @ref, @force_ref = @force_ref, true
        else
          @ref = @cli_opts.fetch('ref', nil)
        end
      end

      def when_inside_repo
        if !@force_ref && @ref && @default && @ref != @default
          raise BranchMismatchError.new(@default, @ref)
        end

        @ref || @default || @repo.current_branch || raise(RefRequired.new(@cli_opts))
      end

      # a.k.a. not in the correct repo
      #
      # returns the ref if it was passed in the cli opts.
      # yields the given block if not set
      def when_outside_repo
        @ref or raise RefAndMigrateRequiredOutsideRepo.new(@cli_opts)
      end

    end
  end
end<commit_msg>Fix a comment<commit_after>require 'engineyard/error'

module EY
  class DeployConfig
    class Ref

      def initialize(cli_opts, env_config, repo)
        @cli_opts  = cli_opts
        @default   = env_config.branch
        @repo      = repo
        @force_ref = @cli_opts.fetch('force_ref', false)

        if @force_ref.kind_of?(String)
          @ref, @force_ref = @force_ref, true
        else
          @ref = @cli_opts.fetch('ref', nil)
        end
      end

      def when_inside_repo
        if !@force_ref && @ref && @default && @ref != @default
          raise BranchMismatchError.new(@default, @ref)
        end

        @ref || @default || @repo.current_branch || raise(RefRequired.new(@cli_opts))
      end

      # a.k.a. not in the correct repo
      #
      # returns the ref if it was passed in the cli opts.
      # or raise
      def when_outside_repo
        @ref or raise RefAndMigrateRequiredOutsideRepo.new(@cli_opts)
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.09639776763064434, 'fraction_numerical': 0.0, 'mean_word_length': 2.110410094637224, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '3380332', 'n_tokens_mistral': 634, 'n_tokens_neox': 619, 'n_words': 164}