<commit_before>module RestoreBundledWith
  class Fetch
    LOCK_FILE = 'Gemfile.lock'
    REF = 'HEAD'
    REGEX_PICK = /^(?<pick>\n^BUNDLED WITH.*\n.+)/
    def initialize(file = LOCK_FILE, ref = REF, git_path = '.', git_options = {})
      @file = file
      @ref = ref
      @git_path = git_path
      @git_options = git_options
    end

    def pick
      match = REGEX_PICK.match(target_file_contents)
      if match
        match[:pick]
      else
        ''
      end
    end

    def target_file_contents
      git.cat_file("#{@ref}:#{@file}")
    end

    def git
      @git ||= ::Git.open(@git_path, @git_options)
    end
  end
end<commit_msg>chore(fetch): comment for capture regex<commit_after>module RestoreBundledWith
  class Fetch
    LOCK_FILE = 'Gemfile.lock'
    REF = 'HEAD'
    # REGEX_PICK = /^(?<pick>\n^BUNDLED WITH.*\n.+\n)/
    # git.cat_file trims last \n?
    REGEX_PICK = /^(?<pick>\n^BUNDLED WITH.*\n.+)/
    def initialize(file = LOCK_FILE, ref = REF, git_path = '.', git_options = {})
      @file = file
      @ref = ref
      @git_path = git_path
      @git_options = git_options
    end

    def pick
      match = REGEX_PICK.match(target_file_contents)
      if match
        match[:pick]
      else
        ''
      end
    end

    def target_file_contents
      git.cat_file("#{@ref}:#{@file}")
    end

    def git
      @git ||= ::Git.open(@git_path, @git_options)
    end
  end
end
{'fraction_non_alphanumeric': 0.13441238564391272, 'fraction_numerical': 0.0, 'mean_word_length': 2.261467889908257, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '6794483', 'n_tokens_mistral': 530, 'n_tokens_neox': 521, 'n_words': 108}