예제 #1
0
def pypi():
    module_name, dry_run, _ = config.common_arguments()

    tmp_dir = make_virtualenv()
    install_cmd = '%s/bin/pip install %s' % (tmp_dir, module_name)

    package_index = 'pypi'
    pypi = config.arguments['--pypi']
    if pypi:
        install_cmd += '-i %s' % pypi
        package_index = pypi

    try:
        result = shell.execute(install_cmd, dry_run=dry_run)
        if result:
            log.info('Successfully installed %s from %s',
                     module_name, package_index)
        else:
            log.error('Failed to install %s from %s',
                      module_name, package_index)

        verification.run_test_command()
    except:
        log.exception(
            'error installing %s from %s', module_name, package_index
        )
        raise Exception(
            'Error installing %s from %s', module_name, package_index
        )

    path(tmp_dir).rmtree(path(tmp_dir))
예제 #2
0
def tag():
    _, dry_run, new_version = config.common_arguments()

    shell.handle_dry_run(sh.git.tag,
                         ('-a', new_version, '-m', '"%s"' % new_version))

    shell.handle_dry_run(sh.git.push, ('--tags'))
예제 #3
0
def pypi():
    module_name, dry_run, _ = config.common_arguments()

    tmp_dir = make_virtualenv()
    install_cmd = '%s/bin/pip install %s' % (tmp_dir, module_name)

    package_index = 'pypi'
    pypi = config.arguments['--pypi']
    if pypi:
        install_cmd += '-i %s' % pypi
        package_index = pypi

    try:
        result = shell.execute(install_cmd, dry_run=dry_run)
        if result:
            log.info('Successfully installed %s from %s', module_name,
                     package_index)
        else:
            log.error('Failed to install %s from %s', module_name,
                      package_index)

        verification.run_test_command()
    except:
        log.exception('error installing %s from %s', module_name,
                      package_index)
        raise Exception('Error installing %s from %s', module_name,
                        package_index)

    path(tmp_dir).rmtree(path(tmp_dir))
예제 #4
0
def commit_version_change():
    module_name, dry_run, new_version = config.common_arguments()

    shell.handle_dry_run(
        sh.git.commit,
        ('-m', new_version, '%s/__init__.py' % module_name, config.CHANGELOG))

    shell.handle_dry_run(sh.git.push, ())
예제 #5
0
파일: version.py 프로젝트: Sureiya/changes
def bump_version():
    module_name, dry_run, new_version = config.common_arguments()

    attributes.replace_attribute(
        module_name,
        '__version__',
        new_version,
        dry_run=dry_run)
예제 #6
0
파일: vcs.py 프로젝트: Sureiya/changes
def commit_version_change():
    module_name, dry_run, new_version = config.common_arguments()

    shell.handle_dry_run(
        sh.git.commit,
        ('-m', new_version, '%s/__init__.py' % module_name, config.CHANGELOG)
    )

    shell.handle_dry_run(sh.git.push, ())
예제 #7
0
파일: vcs.py 프로젝트: Sureiya/changes
def tag():
    _, dry_run, new_version = config.common_arguments()

    shell.handle_dry_run(
        sh.git.tag,
        ('-a', new_version, '-m', '"%s"' % new_version)
    )

    shell.handle_dry_run(sh.git.push, ('--tags'))
예제 #8
0
 def test_common_arguments(self):
     expected_arguments = (
         'changes',
         False,
         '0.0.1',
     )
     self.assertEquals(
         expected_arguments,
         config.common_arguments()
     )
예제 #9
0
def upload():
    module_name, dry_run, new_version = config.common_arguments()
    pypi = config.arguments['--pypi']

    upload_args = 'setup.py clean sdist upload'.split(' ')
    if pypi:
        upload_args.extend(['-r',  pypi])

    upload_result = shell.handle_dry_run(sh.python, tuple(upload_args))
    if not upload_result:
        raise Exception('Error uploading')
    else:
        log.info('Succesfully uploaded %s %s', module_name, new_version)
예제 #10
0
def upload():
    module_name, dry_run, new_version = config.common_arguments()
    pypi = config.arguments['--pypi']

    upload_args = 'setup.py clean sdist upload'.split(' ')
    if pypi:
        upload_args.extend(['-r', pypi])

    upload_result = shell.handle_dry_run(sh.python, tuple(upload_args))
    if not upload_result:
        raise Exception('Error uploading')
    else:
        log.info('Succesfully uploaded %s %s', module_name, new_version)
예제 #11
0
def replace_sha_with_commit_link(git_log_content):
    repo_url = attributes.extract_attribute(config.common_arguments()[0],
                                            '__url__')

    for index, line in enumerate(git_log_content):
        # http://stackoverflow.com/a/468378/5549
        sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line)
        if sha1_re:
            sha1 = sha1_re.group()

            new_line = line.replace(
                sha1, '[%s](%s/commit/%s)' % (sha1, repo_url, sha1))
            log.debug('old line: %s\nnew line: %s', line, new_line)
            git_log_content[index] = new_line

    return git_log_content
예제 #12
0
def changelog():
    module_name, dry_run, new_version = config.common_arguments()

    changelog_content = [
        '\n## [%s](%s/compare/%s...%s)\n\n' % (
            new_version, attributes.extract_attribute(module_name, '__url__'),
            version.current_version(module_name), new_version,
        )
    ]

    git_log_content = None
    try:
        git_log_content = sh.git.log(
            '--oneline',
            '--no-merges',
            '%s..master' % version.current_version(module_name),
            _tty_out=False
        ).split('\n')
        log.debug('content: %s' % git_log_content)
    except:
        log.warn('Error diffing previous version, initial release')

        git_log_content = sh.git.log(
            '--oneline',
            '--no-merges',
            _tty_out=False
        ).split('\n')

    git_log_content = replace_sha_with_commit_link(git_log_content)

    log.debug('content: %s' % git_log_content)

    # makes change log entries into bullet points
    if git_log_content:
        [
            changelog_content.append('* %s\n' % line)
            if line else line
            for line in git_log_content[:-1]
        ]

    write_new_changelog(
        module_name,
        config.CHANGELOG,
        changelog_content,
        dry_run=dry_run
    )
    log.info('Added content to CHANGELOG.md')
예제 #13
0
def changelog():
    module_name, dry_run, new_version = config.common_arguments()

    changelog_content = [
        '\n## [%s](%s/compare/%s...%s)\n\n' % (
            new_version,
            attributes.extract_attribute(module_name, '__url__'),
            version.current_version(module_name),
            new_version,
        )
    ]

    git_log_content = None
    try:
        git_log_content = sh.git.log('--oneline',
                                     '--no-merges',
                                     '%s..master' %
                                     version.current_version(module_name),
                                     _tty_out=False).split('\n')
        log.debug('content: %s' % git_log_content)
    except:
        log.warn('Error diffing previous version, initial release')

        git_log_content = sh.git.log('--oneline',
                                     '--no-merges',
                                     _tty_out=False).split('\n')

    git_log_content = replace_sha_with_commit_link(git_log_content)

    log.debug('content: %s' % git_log_content)

    # makes change log entries into bullet points
    if git_log_content:
        [
            changelog_content.append('* %s\n' % line) if line else line
            for line in git_log_content[:-1]
        ]

    write_new_changelog(module_name,
                        config.CHANGELOG,
                        changelog_content,
                        dry_run=dry_run)
    log.info('Added content to CHANGELOG.md')
예제 #14
0
def replace_sha_with_commit_link(git_log_content):
    repo_url = attributes.extract_attribute(
        config.common_arguments()[0],
        '__url__'
    )

    for index, line in enumerate(git_log_content):
        # http://stackoverflow.com/a/468378/5549
        sha1_re = re.match(r'^[0-9a-f]{5,40}\b', line)
        if sha1_re:
            sha1 = sha1_re.group()

            new_line = line.replace(
                sha1,
                '[%s](%s/commit/%s)' % (sha1, repo_url, sha1)
            )
            log.debug('old line: %s\nnew line: %s', line, new_line)
            git_log_content[index] = new_line

    return git_log_content
예제 #15
0
def install():
    module_name, dry_run, new_version = config.common_arguments()
    commands = ['setup.py', 'clean', 'sdist']
    if probe.has_requirement('wheel'):
        commands.append('bdist_wheel')
    result = shell.handle_dry_run(sh.python, tuple(commands))
    if result:
        tmp_dir = make_virtualenv()
        package_name = config.arguments.get('--package-name') or module_name
        try:
            virtualenv.install_sdist(
                config.arguments['<module_name>'],
                'dist/%s-%s.tar.gz' % (package_name, new_version),
                '%s/bin/python' % tmp_dir)
            log.info('Successfully installed %s sdist', module_name)
            if verification.run_test_command():
                log.info('Successfully ran test command: %s',
                         config.arguments['--test-command'])
        except:
            raise Exception('Error installing %s sdist', module_name)

        path(tmp_dir).rmtree(path(tmp_dir))
예제 #16
0
def install():
    module_name, dry_run, new_version = config.common_arguments()
    commands = ['setup.py', 'clean', 'sdist']
    if probe.has_requirement('wheel'):
        commands.append('bdist_wheel')
    result = shell.handle_dry_run(sh.python, tuple(commands))
    if result:
        tmp_dir = make_virtualenv()
        package_name = config.arguments.get('--package-name') or module_name
        try:
            virtualenv.install_sdist(
                config.arguments['<module_name>'],
                'dist/%s-%s.tar.gz' % (package_name, new_version),
                '%s/bin/python' % tmp_dir
            )
            log.info('Successfully installed %s sdist', module_name)
            if verification.run_test_command():
                log.info('Successfully ran test command: %s',
                         config.arguments['--test-command'])
        except:
            raise Exception('Error installing %s sdist', module_name)

        path(tmp_dir).rmtree(path(tmp_dir))