<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess
from ..utils import DEVNULL, change_working_directory
from .base import DOWNLOAD_CONTAINER


def download(source_info):
    url = source_info['git']
    subprocess.call(
        ('git', 'clone', url, DOWNLOAD_CONTAINER),
        stdout=DEVNULL, stderr=subprocess.STDOUT,
    )
    if 'tag' in source_info:
        with change_working_directory(DOWNLOAD_CONTAINER):
            subprocess.call(
                ('git', 'checkout', source_info['tag']),
                stdout=DEVNULL, stderr=subprocess.STDOUT,
            )<commit_msg>Add auto branch checkout functionality<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import subprocess
from ..utils import DEVNULL, change_working_directory
from .base import DOWNLOAD_CONTAINER


def _checkout(name):
    with change_working_directory(DOWNLOAD_CONTAINER):
        subprocess.call(
            ('git', 'checkout', name),
            stdout=DEVNULL, stderr=subprocess.STDOUT,
        )


def download(source_info):
    url = source_info['git']
    subprocess.call(
        ('git', 'clone', url, DOWNLOAD_CONTAINER),
        stdout=DEVNULL, stderr=subprocess.STDOUT,
    )
    if 'tag' in source_info:
        _checkout(source_info['tag'])
    elif 'branch' in source_info:
        _checkout(source_info['branch'])
{'fraction_non_alphanumeric': 0.11955719557195572, 'fraction_numerical': 0.0014760147601476014, 'mean_word_length': 3.121580547112462, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2104413', 'n_tokens_mistral': 442, 'n_tokens_neox': 412, 'n_words': 88}