<commit_before>from dulwich.client import LocalGitClient


def stage_file(repo, file):
    file_path = str(file.relative_to(repo.path))
    repo.stage(file_path)


def commit(repo, message):
    message = bytes(message, encoding='UTF-8')
    repo.do_commit(message)


def fetch_all(source_repo, target_repo, remote_name=None):
    if remote_name is None:
        remote_name = 'origin'

    refs = LocalGitClient().fetch(source_repo.path, target_repo)

    for key, value in refs.items():
        key = key.replace(
            b'heads', b'remotes/%s' % bytes(remote_name, encoding='UTF-8'))
        target_repo.refs[key] = value<commit_msg>Create git.checkout<commit_after>from dulwich.client import LocalGitClient
from dulwich.index import build_index_from_tree


def stage_file(repo, file):
    file_path = str(file.relative_to(repo.path))
    repo.stage(file_path)


def commit(repo, message):
    message = bytes(message, encoding='UTF-8')
    repo.do_commit(message)


def fetch_all(source_repo, target_repo, remote_name=None):
    if remote_name is None:
        remote_name = 'origin'

    refs = LocalGitClient().fetch(source_repo.path, target_repo)

    for key, value in refs.items():
        key = key.replace(
            b'heads', b'remotes/%s' % bytes(remote_name, encoding='UTF-8'))
        target_repo.refs[key] = value


def checkout(repo, ref=None):
    if ref is None:
        ref = 'HEAD'
    index = repo.index_path()
    tree_id = repo[ref].tree
    build_index_from_tree(repo.path,index, repo.object_store, tree_id)
{'fraction_non_alphanumeric': 0.11955815464587394, 'fraction_numerical': 0.002599090318388564, 'mean_word_length': 3.7384615384615385, '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': '2303816', 'n_tokens_mistral': 526, 'n_tokens_neox': 505, 'n_words': 106}