def fail(msg):
    if work_dir:
        cmd('Cleaning up work directory', ('rm -rf %s' % work_dir))
    if delete_gitrefs:
        try:
            cmd(('Resetting repository working state to branch %s' % starting_branch), ('git reset --hard HEAD && git checkout %s' % starting_branch), shell=True)
            cmd(('Deleting git branches %s' % release_version), ('git branch -D %s' % release_version), shell=True)
            cmd(('Deleting git tag %s' % rc_tag), ('git tag -d %s' % rc_tag), shell=True)
        except subprocess.CalledProcessError:
            print('Failed when trying to clean up git references added by this script. You may need to clean up branches/tags yourself before retrying.')
            print(('Expected git branch: ' + release_version))
            print(('Expected git tag: ' + rc_tag))
    print(msg)
    sys.exit(1)
def fail(msg):
    if work_dir:
        cmd('Cleaning up work directory', ('rm -rf %s' % work_dir))
    if delete_gitrefs:
        try:
            cmd(('Resetting repository working state to branch %s' % starting_branch), ('git reset --hard HEAD && git checkout %s' % starting_branch), shell=True)
            cmd(('Deleting git branches %s' % release_version), ('git branch -D %s' % release_version), shell=True)
            cmd(('Deleting git tag %s' % rc_tag), ('git tag -d %s' % rc_tag), shell=True)
        except subprocess.CalledProcessError:
            print('Failed when trying to clean up git references added by this script. You may need to clean up branches/tags yourself before retrying.')
            print(('Expected git branch: ' + release_version))
            print(('Expected git tag: ' + rc_tag))
    print(msg)
    sys.exit(1)