<commit_before>from functools import wraps
import logging

from . import process
from .utils import which, tempdir


def ensure_git(return_value=None):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if which('git'):
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    logging.debug(str(e))
            else:
                logging.debug('git is not installed')
            return return_value
        return wrapper
    return decorator


@ensure_git()
def clone(url, dest=None):
    dest = dest if dest else tempdir()
    cmd = ['git', 'clone', url, dest]
    process.call(cmd)
    return dest


class Repository(object):

    def __init__(self, path, autopull=None, autopush=None):
        self.path = path
        self.autopush = autopush
        self.autopull = autopull
        if autopull:
            self.pull_rebase(*autopull)

    @ensure_git()
    def init(self):
        cmd = ['git', 'init', self.path]
        process.call(cmd, cwd=self.path)

    @ensure_git()
    def pull_rebase(self, remote='origin', branch='master'):
        cmd = ['git', 'pull', '--rebase', remote, branch]
        process.call(cmd, cwd=self.path)

    @ensure_git()
    def push(self, remote='origin', branch='master'):
        cmd = ['git', 'push', remote, branch]
        process.call(cmd, cwd=self.path)

    @ensure_git()
    def add(self, all=False):
        if all is True:
            cmd = ['git', 'add', '--all', '.']
        else:
            cmd = ['git', 'add', '.']<commit_msg>Fix error creating subdir in database in git init<commit_after>from functools import wraps
import logging

from . import process
from .utils import which, tempdir


def ensure_git(return_value=None):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if which('git'):
                try:
                    return func(*args, **kwargs)
                except Exception as e:
                    logging.debug(str(e))
            else:
                logging.debug('git is not installed')
            return return_value
        return wrapper
    return decorator


@ensure_git()
def clone(url, dest=None):
    dest = dest if dest else tempdir()
    cmd = ['git', 'clone', url, dest]
    process.call(cmd)
    return dest


class Repository(object):

    def __init__(self, path, autopull=None, autopush=None):
        self.path = path
        self.autopush = autopush
        self.autopull = autopull
        if autopull:
            self.pull_rebase(*autopull)

    @ensure_git()
    def init(self):
        cmd = ['git', 'init', self.path]
        process.call(cmd)

    @ensure_git()
    def pull_rebase(self, remote='origin', branch='master'):
        cmd = ['git', 'pull', '--rebase', remote, branch]
        process.call(cmd, cwd=self.path)

    @ensure_git()
    def push(self, remote='origin', branch='master'):
        cmd = ['git', 'push', remote, branch]
        process.call(cmd, cwd=self.path)

    @ensure_git()
    def add(self, all=False):
        if all is True:
            cmd = ['git', 'add', '--all', '.']
        else:
            cmd = ['git', 'add', '.']
{'fraction_non_alphanumeric': 0.13454995360346428, 'fraction_numerical': 0.0, 'mean_word_length': 2.1246376811594203, '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': '1259251', 'n_tokens_mistral': 995, 'n_tokens_neox': 971, 'n_words': 263}