def update_changelog_and_version():
    global __version_info__
    global __version__

    contents = changelog()
    assert '\r' not in contents
    lines = contents.split('\n')
    for i, l in enumerate(lines):
        if CHANGELOG_ANCHOR.match(l):
            assert CHANGELOG_BORDER.match(lines[i + 2]), repr(lines[i + 2])
            assert CHANGELOG_HEADER.match(lines[i + 3]), repr(lines[i + 3])
            assert CHANGELOG_BORDER.match(lines[i + 4]), repr(lines[i + 4])
            beginning = '\n'.join(lines[:i])
            rest = '\n'.join(lines[i:])
            assert '\n'.join((beginning, rest)) == contents
            break

    release_type, release_contents = parse_release_file()

    new_version_string, new_version_info = rm.bump_version_info(
        __version_info__, release_type)

    __version_info__ = new_version_info
    __version__ = new_version_string

    rm.replace_assignment(
        VERSION_FILE, '__version_info__', repr(new_version_info))

    heading_for_new_version = ' - '.join((
        new_version_string, rm.release_date_string()))
    border_for_new_version = '-' * len(heading_for_new_version)

    new_changelog_parts = [
        beginning.strip(),
        '',
        '.. _v%s:' % (new_version_string),
        '',
        border_for_new_version,
        heading_for_new_version,
        border_for_new_version,
        '',
        release_contents,
        '',
        rest
    ]

    with open(CHANGELOG_FILE, 'w') as o:
        o.write('\n'.join(new_changelog_parts))
def update_changelog_and_version():
    """Update the changelog and version based on the current release file."""
    release_type, release_contents = rm.parse_release_file(RELEASE_FILE)
    version = current_version()
    version_info = rm.parse_version(version)

    version, version_info = rm.bump_version_info(version_info, release_type)

    rm.replace_assignment(CARGO_FILE, "version", repr(version))

    rm.update_markdown_changelog(
        CHANGELOG_FILE,
        name="Conjecture for Rust",
        version=version,
        entry=release_contents,
    )
    os.unlink(RELEASE_FILE)
def update_changelog_and_version():
    """Update the changelog and version based on the current release file."""
    release_type, release_contents = parse_release_file()
    version = current_version()
    version_info = rm.parse_version(version)

    version, version_info = rm.bump_version_info(version_info, release_type)

    rm.replace_assignment(GEMSPEC_FILE, 's.version', repr(version))
    rm.replace_assignment(
        GEMSPEC_FILE, 's.date', repr(rm.release_date_string())
    )

    rm.update_markdown_changelog(
        CHANGELOG_FILE,
        name='Hypothesis for Ruby',
        version=version,
        entry=release_contents,
    )
    os.unlink(RELEASE_FILE)
def update_changelog_and_version():
    global __version_info__
    global __version__

    contents = changelog()
    assert '\r' not in contents
    lines = contents.split('\n')
    for i, l in enumerate(lines):
        if CHANGELOG_ANCHOR.match(l):
            assert CHANGELOG_BORDER.match(lines[i + 2]), repr(lines[i + 2])
            assert CHANGELOG_HEADER.match(lines[i + 3]), repr(lines[i + 3])
            assert CHANGELOG_BORDER.match(lines[i + 4]), repr(lines[i + 4])
            beginning = '\n'.join(lines[:i])
            rest = '\n'.join(lines[i:])
            assert '\n'.join((beginning, rest)) == contents
            break

    release_type, release_contents = parse_release_file()

    new_version_string, new_version_info = rm.bump_version_info(
        __version_info__, release_type)

    __version_info__ = new_version_info
    __version__ = new_version_string

    rm.replace_assignment(VERSION_FILE, '__version_info__',
                          repr(new_version_info))

    heading_for_new_version = ' - '.join(
        (new_version_string, rm.release_date_string()))
    border_for_new_version = '-' * len(heading_for_new_version)

    new_changelog_parts = [
        beginning.strip(), '',
        '.. _v%s:' % (new_version_string), '', border_for_new_version,
        heading_for_new_version, border_for_new_version, '', release_contents,
        '', rest
    ]

    with open(CHANGELOG_FILE, 'w') as o:
        o.write('\n'.join(new_changelog_parts))
def update_changelog_and_version():
    global __version_info__
    global __version__

    contents = changelog()
    assert "\r" not in contents
    lines = contents.split("\n")
    for i, l in enumerate(lines):
        if CHANGELOG_ANCHOR.match(l):
            assert CHANGELOG_BORDER.match(lines[i + 2]), repr(lines[i + 2])
            assert CHANGELOG_HEADER.match(lines[i + 3]), repr(lines[i + 3])
            assert CHANGELOG_BORDER.match(lines[i + 4]), repr(lines[i + 4])
            beginning = "\n".join(lines[:i])
            rest = "\n".join(lines[i:])
            assert "\n".join((beginning, rest)) == contents
            break

    release_type, release_contents = parse_release_file()

    new_version_string, new_version_info = rm.bump_version_info(
        __version_info__, release_type
    )

    __version_info__ = new_version_info
    __version__ = new_version_string

    if release_type == "major":
        major, _, _ = __version_info__
        old = f"Hypothesis {major - 1}.x"
        beginning = beginning.replace(old, f"Hypothesis {major}.x")
        rest = "\n".join([old, len(old) * "=", "", rest])

    rm.replace_assignment(VERSION_FILE, "__version_info__", repr(new_version_info))

    heading_for_new_version = " - ".join((new_version_string, rm.release_date_string()))
    border_for_new_version = "-" * len(heading_for_new_version)

    new_changelog_parts = [
        beginning.strip(),
        "",
        ".. _v%s:" % (new_version_string),
        "",
        border_for_new_version,
        heading_for_new_version,
        border_for_new_version,
        "",
        release_contents,
        "",
        rest,
    ]

    with open(CHANGELOG_FILE, "w") as o:
        o.write("\n".join(new_changelog_parts))

    # Replace the `since="RELEASEDAY"` argument to `note_deprecation`
    # with today's date, to record it for future reference.
    before = 'since="RELEASEDAY"'
    after = before.replace("RELEASEDAY", rm.release_date_string())
    for root, _, files in os.walk(PYTHON_SRC):
        for fname in (os.path.join(root, f) for f in files if f.endswith(".py")):
            with open(fname) as f:
                contents = f.read()
            if before in contents:
                with open(fname, "w") as f:
                    f.write(contents.replace(before, after))
def test_bump_minor_version():
    assert bump_version_info((1, 1, 1), "minor")[0] == "1.2.0"
def test_bump_minor_version():
    assert bump_version_info((1, 1, 1), 'minor')[0] == '1.2.0'
def test_bump_minor_version():
    assert bump_version_info((1, 1, 1), "minor")[0] == "1.2.0"