<commit_before>"""Tasks that deal with deployment."""

from fabric.api import abort, hide, lcd, local, task

import heroku
from settings import PROJECT_ROOT
from utils import get_tag_names, is_working_directory_clean, msg, need_to_tag


@task
def prepare_to_deploy():
    """Prepare the project's working copy for deployment."""
    with lcd(PROJECT_ROOT), hide('commands'):
        if not is_working_directory_clean():
            abort("Working directory must be clean before deployment.")
        local('git pull')


@task
def tag_project(prefix):
    """Tag the project for the specified environment."""
    if prefix is None:
        abort('Tag prefix must be specified!')

    with lcd(PROJECT_ROOT), hide('commands'):
        (last_tag_name, next_tag_name) = get_tag_names(prefix)

        print('Last tag: %s' % last_tag_name)
        print('Next tag: %s' % next_tag_name)

        if not need_to_tag("HEAD", last_tag_name):
            print("Current tag '%s' is the most recent version." % last_tag_name)
            return

        with msg("Tagging project with '%s'" % next_tag_name):
            local('git tag -a -m "Tag latest for %s." %s' % (prefix, next_tag_name))


@task
def deploy_to_heroku():
    """Deploy the site to Heroku."""
    with lcd(PROJECT_ROOT):
        with heroku.maintenance(), hide('running'):
            local("git push heroku")
            local("heroku run python manage.py syncdb --noinput")
            # TODO: Integrate South to support database migration.
            #local("heroku run python manage.py migrate")<commit_msg>Print the tagging message instead of using the msg() contextmanager.<commit_after>"""Tasks that deal with deployment."""

from fabric.api import abort, hide, lcd, local, task

import heroku
from settings import PROJECT_ROOT
from utils import get_tag_names, is_working_directory_clean, need_to_tag


@task
def prepare_to_deploy():
    """Prepare the project's working copy for deployment."""
    with lcd(PROJECT_ROOT), hide('commands'):
        if not is_working_directory_clean():
            abort("Working directory must be clean before deployment.")
        local('git pull')


@task
def tag_project(prefix):
    """Tag the project for the specified environment."""
    if prefix is None:
        abort('Tag prefix must be specified!')

    with lcd(PROJECT_ROOT), hide('commands'):
        (last_tag_name, next_tag_name) = get_tag_names(prefix)

        print('Last tag: %s' % last_tag_name)
        print('Next tag: %s' % next_tag_name)

        if not need_to_tag("HEAD", last_tag_name):
            print("Current tag '%s' is the most recent version." % last_tag_name)
            return

        print("Tagging project with '%s'." % next_tag_name)
        local('git tag -a -m "Tag latest for %s." %s' % (prefix, next_tag_name))


@task
def deploy_to_heroku():
    """Deploy the site to Heroku."""
    with lcd(PROJECT_ROOT):
        with heroku.maintenance(), hide('running'):
            local("git push heroku")
            local("heroku run python manage.py syncdb --noinput")
            # TODO: Integrate South to support database migration.
            #local("heroku run python manage.py migrate")
{'fraction_non_alphanumeric': 0.11177394034536892, 'fraction_numerical': 0.0, 'mean_word_length': 3.170157068062827, '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': '302689', 'n_tokens_mistral': 929, 'n_tokens_neox': 912, 'n_words': 304}