<commit_before>import os
import re
import subprocess

from typing import List, Optional

from .config import DEBUG

__all__ = ["Repository"]

def call_git(*args: str, cwd: str, git_exec: str = "/usr/bin/git") -> str:
    to_exec = [git_exec] + list(args)

    if DEBUG:
        print(to_exec)
        print(cwd)
    return subprocess.check_output(to_exec, cwd=cwd).decode('utf-8')


class Repository(object):
    def __init__(self, path: str, *, branch_name: str = "master"):
        self.path = path
        self.branch_name = branch_name

    def __call_git(self, *args: str) -> str:
        return call_git(*args, cwd=self.path)

    def commits(self, reachable_from: Optional[str] = None, merges_only: bool = False) -> List[str]:
        args = ["log", "--pretty=format:%H"]
        if reachable_from:
            args.append(reachable_from)
        if merges_only:
            args.append("--merges")
        return self.__call_git(*args).split()

    def message(self, commit_hash: str) -> str:<commit_msg>Always use specified branch<commit_after>import os
import re
import subprocess

from typing import List, Optional

from .config import DEBUG

__all__ = ["Repository"]

def call_git(*args: str, cwd: str, git_exec: str = "/usr/bin/git") -> str:
    to_exec = [git_exec] + list(args)

    if DEBUG:
        print(to_exec)
        print(cwd)
    return subprocess.check_output(to_exec, cwd=cwd).decode('utf-8')


class Repository(object):
    def __init__(self, path: str, *, branch_name: str = "master"):
        self.path = path
        self.branch_name = branch_name

        # Make sure we're using the appropriate branch
        self.__call_git("symbolic-ref", "HEAD", f"refs/heads/{branch_name}")

    def __call_git(self, *args: str) -> str:
        return call_git(*args, cwd=self.path)

    def commits(self, reachable_from: Optional[str] = None, merges_only: bool = False) -> List[str]:
        args = ["log", "--pretty=format:%H"]
        if reachable_from:
            args.append(reachable_from)
        if merges_only:
            args.append("--merges")
        return self.__call_git(*args).split()

    def message(self, commit_hash: str) -> str:
{'fraction_non_alphanumeric': 0.13357899585444497, 'fraction_numerical': 0.0009212344541685859, 'mean_word_length': 3.022222222222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4764152', 'n_tokens_mistral': 719, 'n_tokens_neox': 704, 'n_words': 176}