Пример #1
0
def changelog(**kwargs):
    """
    Generates the changelog since the last release.
    """
    current_version = get_current_version()
    if current_version is None:
        raise ImproperConfigurationError(
            "Unable to get the current version. "
            "Make sure semantic_release.version_variable "
            "is setup correctly")
    previous_version = get_previous_version(current_version)

    log = generate_changelog(previous_version, current_version)
    for section in CHANGELOG_SECTIONS:
        if not log[section]:
            continue

        click.echo(section.capitalize())
        click.echo(''.join(['-' for i in range(len(section))]))
        for item in log[section]:
            click.echo(' - {0} ({1})'.format(item[1], item[0]))
        click.echo('\n')

    if not kwargs.get('noop') and kwargs.get('post'):
        if check_token():
            owner, name = get_repository_owner_and_name()
            click.echo('Updating changelog')
            post_changelog(
                owner, name, current_version,
                markdown_changelog(current_version, log, header=False))
        else:
            click.echo(click.style('Missing token: cannot post changelog',
                                   'red'),
                       err=True)
Пример #2
0
def changelog(**kwargs):
    """
    Generates the changelog since the last release.
    :raises ImproperConfigurationError: if there is no current version
    """
    current_version = get_current_version()
    debug('changelog got current_version', current_version)

    if current_version is None:
        raise ImproperConfigurationError(
            "Unable to get the current version. "
            "Make sure semantic_release.version_variable "
            "is setup correctly")
    previous_version = get_previous_version(current_version)
    debug('changelog got previous_version', previous_version)

    if kwargs['unreleased']:
        log = generate_changelog(current_version, None)
    else:
        log = generate_changelog(previous_version, current_version)
    click.echo(markdown_changelog(current_version, log, header=False))

    debug('noop={}, post={}'.format(kwargs.get('noop'), kwargs.get('post')))
    if not kwargs.get('noop') and kwargs.get('post'):
        if check_token():
            owner, name = get_repository_owner_and_name()
            click.echo('Updating changelog')
            post_changelog(
                owner, name, current_version,
                markdown_changelog(current_version, log, header=False))
        else:
            click.echo(click.style('Missing token: cannot post changelog',
                                   'red'),
                       err=True)
Пример #3
0
def changelog(**kwargs):
    """
    Generate the changelog since the last release.

    :raises ImproperConfigurationError: if there is no current version
    """
    current_version = get_current_version()
    if current_version is None:
        raise ImproperConfigurationError(
            "Unable to get the current version. "
            "Make sure semantic_release.version_variable "
            "is setup correctly")

    previous_version = get_previous_version(current_version)

    # Generate the changelog
    if kwargs["unreleased"]:
        log = generate_changelog(current_version, None)
    else:
        log = generate_changelog(previous_version, current_version)
    logger.info(markdown_changelog(current_version, log, header=False))

    # Post changelog to HVCS if enabled
    if not kwargs.get("noop") and kwargs.get("post"):
        if check_token():
            owner, name = get_repository_owner_and_name()
            logger.info("Posting changelog to HVCS")
            post_changelog(
                owner,
                name,
                current_version,
                markdown_changelog(current_version, log, header=False),
            )
        else:
            logger.error("Missing token: cannot post changelog to HVCS")
Пример #4
0
def changelog(*,
              unreleased=False,
              noop=False,
              post=False,
              prerelease=False,
              **kwargs):
    """
    Generate the changelog since the last release.

    :raises ImproperConfigurationError: if there is no current version
    """
    current_version = get_current_version()
    if current_version is None:
        raise ImproperConfigurationError(
            "Unable to get the current version. "
            "Make sure semantic_release.version_variable "
            "is setup correctly")

    previous_version = get_previous_version(current_version)

    # Generate the changelog
    if unreleased:
        log = generate_changelog(current_version, None)
    else:
        log = generate_changelog(previous_version, current_version)

    owner, name = get_repository_owner_and_name()
    # print is used to keep the changelog on stdout, separate from log messages
    print(markdown_changelog(owner, name, current_version, log, header=False))

    # Post changelog to HVCS if enabled
    if not noop and post:
        if check_token():
            logger.info("Posting changelog to HVCS")
            post_changelog(
                owner,
                name,
                current_version,
                markdown_changelog(owner,
                                   name,
                                   current_version,
                                   log,
                                   header=False),
            )
        else:
            logger.error("Missing token: cannot post changelog to HVCS")