<commit_before>module Causes
  module GitHook
    module FileMethods
      def modified_files(type=nil)
        @modified_files ||= `git diff --cached --name-only --diff-filter=ACM`.split
        type ? @modified_files.select { |f| f =~ /\.#{type}$/ } : @modified_files
      end

      def staged_files(*args)
        modified_files(*args).map { |filename| StagedFile.new(filename) }
      end

      def in_path?(cmd)
        system("which #{cmd} &> /dev/null")
      end
    end
  end
end<commit_msg>Teach FileMethods#modified_files to filter by path<commit_after>module Causes
  module GitHook
    module FileMethods
      def modified_files(type=nil, path=nil)
        @modified_files ||=
          `git diff --cached --name-only --diff-filter=ACM -- #{path}`.split "\n"
        type ? @modified_files.select { |f| f =~ /\.#{type}$/ } : @modified_files
      end

      def staged_files(*args)
        modified_files(*args).map { |filename| StagedFile.new(filename) }
      end

      def in_path?(cmd)
        system("which #{cmd} &> /dev/null")
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1380908248378128, 'fraction_numerical': 0.0, 'mean_word_length': 2.472668810289389, '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': '6468745', 'n_tokens_mistral': 351, 'n_tokens_neox': 346, 'n_words': 79}