<commit_before>from git import Repo
import logging
from .common import sha256_hash, home_directory_path, path_exists

FOLDER = '.foolbox_zoo'


class GitCloneError(RuntimeError):
    pass


def clone(git_uri):
    """
    :param git_uri:
    :return:
    """
    hash_digest = sha256_hash(git_uri)
    local_path = home_directory_path(FOLDER, hash_digest)
    exists_locally = path_exists(local_path)

    if not exists_locally:
        _clone_repo(git_uri, local_path)
    else:
        logging.info("Git repository already exists locally.")

    return local_path


def _clone_repo(git_uri, local_path):
    logging.info("Cloning repo %s to %s", git_uri, local_path)
    try:
        Repo.clone_from(git_uri, local_path)
    except Exception as e:
        logging.exception("Failed to clone repository", e)
        raise GitCloneError("Failed to clone repository")
    logging.info("Cloned repo successfully.")<commit_msg>add pragma: no cover to logging line<commit_after>from git import Repo
import logging
from .common import sha256_hash, home_directory_path, path_exists

FOLDER = '.foolbox_zoo'


class GitCloneError(RuntimeError):
    pass


def clone(git_uri):
    """
    :param git_uri:
    :return:
    """
    hash_digest = sha256_hash(git_uri)
    local_path = home_directory_path(FOLDER, hash_digest)
    exists_locally = path_exists(local_path)

    if not exists_locally:
        _clone_repo(git_uri, local_path)
    else:
        logging.info("Git repository already exists locally.")  # pragma: no cover

    return local_path


def _clone_repo(git_uri, local_path):
    logging.info("Cloning repo %s to %s", git_uri, local_path)
    try:
        Repo.clone_from(git_uri, local_path)
    except Exception as e:
        logging.exception("Failed to clone repository", e)
        raise GitCloneError("Failed to clone repository")
    logging.info("Cloned repo successfully.")
{'fraction_non_alphanumeric': 0.08831306187202538, 'fraction_numerical': 0.006345848757271285, 'mean_word_length': 3.7064676616915424, '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': '4006378', 'n_tokens_mistral': 618, 'n_tokens_neox': 597, 'n_words': 152}