<commit_before>module Airbrake
  module Filters
    # Attaches git repository URL to `context`.
    # @api private
    # @since v2.12.0
    class GitRepositoryFilter
      # @return [Integer]
      attr_reader :weight

      # @param [String] root_directory
      def initialize(root_directory)
        @git_path = File.join(root_directory, '.git')
        @repository = nil
        @git_version = Gem::Version.new(`git --version`.split.last)
        @weight = 116
      end

      # @macro call_filter
      def call(notice)
        return if notice[:context].key?(:repository)

        if @repository
          notice[:context][:repository] = @repository
          return
        end

        return unless File.exist?(@git_path)

        @repository =
          if @git_version >= Gem::Version.new('2.7.0')
            `cd #{@git_path} && git remote get-url origin`.chomp
          else<commit_msg>filters/git_repository: read remote through config<commit_after>module Airbrake
  module Filters
    # Attaches git repository URL to `context`.
    # @api private
    # @since v2.12.0
    class GitRepositoryFilter
      # @return [Integer]
      attr_reader :weight

      # @param [String] root_directory
      def initialize(root_directory)
        @git_path = File.join(root_directory, '.git')
        @repository = nil
        @git_version = Gem::Version.new(`git --version`.split.last)
        @weight = 116
      end

      # @macro call_filter
      def call(notice)
        return if notice[:context].key?(:repository)

        if @repository
          notice[:context][:repository] = @repository
          return
        end

        return unless File.exist?(@git_path)

        @repository =
          if @git_version >= Gem::Version.new('2.7.0')
            `cd #{@git_path} && git config --get remote.origin.url`.chomp
          else
{'fraction_non_alphanumeric': 0.11093073593073594, 'fraction_numerical': 0.010822510822510822, 'mean_word_length': 2.2268760907504364, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6809745', 'n_tokens_mistral': 539, 'n_tokens_neox': 518, 'n_words': 129}