tasks/release.py
def update_changelog(ctx, new_version):
    """
    Quick task to generate the new CHANGELOG using reno when releasing a minor
    version (linux/macOS only).
    """
    new_version_int = list(map(int, new_version.split(".")))

    if len(new_version_int) != 3:
        print(f"Error: invalid version: {new_version_int}")
        raise Exit(1)

    # let's avoid losing uncommitted change with 'git reset --hard'
    try:
        ctx.run("git diff --exit-code HEAD", hide="both")
    except Failure:
        print("Error: You have uncommitted change, please commit or stash before using update_changelog")
        return

    # make sure we are up to date
    ctx.run("git fetch")

    # let's check that the tag for the new version is present (needed by reno)
    try:
        ctx.run(f"git tag --list | grep {new_version}")
    except Failure:
        print(f"Missing '{new_version}' git tag: mandatory to use 'reno'")
        raise

    # removing releasenotes from bugfix on the old minor.
    branching_point = f"{new_version_int[0]}.{new_version_int[1]}.0-devel"
    previous_minor = f"{new_version_int[0]}.{new_version_int[1] - 1}"
    if previous_minor == "7.15":
        previous_minor = "6.15"  # 7.15 is the first release in the 7.x series
    log_result = ctx.run(
        f"git log {branching_point}...remotes/origin/{previous_minor}.x --name-only --oneline |             grep releasenotes/notes/ || true"
    )
    log_result = log_result.stdout.replace('\n', ' ').strip()
    if len(log_result) > 0:
        ctx.run(f"git rm --ignore-unmatch {log_result}")

    # generate the new changelog
    ctx.run(
        f"reno report             --ignore-cache             --earliest-version {branching_point}             --version {new_version}             --no-show-source > /tmp/new_changelog.rst"
    )

    # reseting git
    ctx.run("git reset --hard HEAD")

    # mac's `sed` has a different syntax for the "-i" paramter
    sed_i_arg = "-i"
    if sys.platform == 'darwin':
        sed_i_arg = "-i ''"
    # check whether there is a v6 tag on the same v7 tag, if so add the v6 tag to the release title
    v6_tag = ""
    if new_version_int[0] == 7:
        v6_tag = _find_v6_tag(ctx, new_version)
        if v6_tag:
            ctx.run(f"sed {sed_i_arg} -E 's#^{new_version}#{new_version} / {v6_tag}#' /tmp/new_changelog.rst")
    # remove the old header from the existing changelog
    ctx.run(f"sed {sed_i_arg} -e '1,4d' CHANGELOG.rst")

    # merging to CHANGELOG.rst
    ctx.run("cat CHANGELOG.rst >> /tmp/new_changelog.rst && mv /tmp/new_changelog.rst CHANGELOG.rst")

    # commit new CHANGELOG
    ctx.run("git add CHANGELOG.rst")

    print("\nCommit this with:")
    print(f"git commit -m \"[DCA] Update CHANGELOG for {new_version}\"")

    Quick task to generate the new CHANGELOG using reno when releasing a minor
    version (linux/macOS only).
    
Quick task to generate the new CHANGELOG using reno when releasing a minor
version (linux/macOS only).
Quick task to generate the new CHANGELOG using reno when releasing a minor version ( linux / macOS only ) .
def update_changelog(ctx, new_version):
    new_version_int = list(map(int, new_version.split(".")))
    if len(new_version_int) != 3:
        print(f"Error: invalid version: {new_version_int}")
        raise Exit(1)
    try:
        ctx.run("git diff --exit-code HEAD", hide="both")
    except Failure:
        print("Error: You have uncommitted change, please commit or stash before using update_changelog")
        return
    ctx.run("git fetch")
    try:
        ctx.run(f"git tag --list | grep {new_version}")
    except Failure:
        print(f"Missing '{new_version}' git tag: mandatory to use 'reno'")
        raise
    branching_point = f"{new_version_int[0]}.{new_version_int[1]}.0-devel"
    previous_minor = f"{new_version_int[0]}.{new_version_int[1] - 1}"
    if previous_minor == "7.15":
        previous_minor = "6.15"  
    log_result = ctx.run(
        f"git log {branching_point}...remotes/origin/{previous_minor}.x --name-only --oneline |             grep releasenotes/notes/ || true"
    )
    log_result = log_result.stdout.replace('\n', ' ').strip()
    if len(log_result) > 0:
        ctx.run(f"git rm --ignore-unmatch {log_result}")
    ctx.run(
        f"reno report             --ignore-cache             --earliest-version {branching_point}             --version {new_version}             --no-show-source > /tmp/new_changelog.rst"
    )
    ctx.run("git reset --hard HEAD")
    sed_i_arg = "-i"
    if sys.platform == 'darwin':
        sed_i_arg = "-i ''"
    v6_tag = ""
    if new_version_int[0] == 7:
        v6_tag = _find_v6_tag(ctx, new_version)
        if v6_tag:
            ctx.run(f"sed {sed_i_arg} -E 's#^{new_version}#{new_version} / {v6_tag}#' /tmp/new_changelog.rst")
    ctx.run(f"sed {sed_i_arg} -e '1,4d' CHANGELOG.rst")
    ctx.run("cat CHANGELOG.rst >> /tmp/new_changelog.rst && mv /tmp/new_changelog.rst CHANGELOG.rst")
    ctx.run("git add CHANGELOG.rst")
    print("\nCommit this with:")
    print(f"git commit -m \"[DCA] Update CHANGELOG for {new_version}\"")
def update_changelog ( ctx , new_version ) : new_version_int = list ( map ( int , new_version . split ( "." ) ) ) if len ( new_version_int ) != 3 : print ( f"Error: invalid version: {new_version_int}" ) raise Exit ( 1 ) try : ctx . run ( "git diff --exit-code HEAD" , hide = "both" ) except Failure : print ( "Error: You have uncommitted change, please commit or stash before using update_changelog" ) return ctx . run ( "git fetch" ) try : ctx . run ( f"git tag --list | grep {new_version}" ) except Failure : print ( f"Missing '{new_version}' git tag: mandatory to use 'reno'" ) raise branching_point = f"{new_version_int[0]}.{new_version_int[1]}.0-devel" previous_minor = f"{new_version_int[0]}.{new_version_int[1] - 1}" if previous_minor == "7.15" : previous_minor = "6.15" log_result = ctx . run ( f"git log {branching_point}...remotes/origin/{previous_minor}.x --name-only --oneline |             grep releasenotes/notes/ || true" ) log_result = log_result . stdout . replace ( '\n' , ' ' ) . strip ( ) if len ( log_result ) > 0 : ctx . run ( f"git rm --ignore-unmatch {log_result}" ) ctx . run ( f"reno report             --ignore-cache             --earliest-version {branching_point}             --version {new_version}             --no-show-source > /tmp/new_changelog.rst" ) ctx . run ( "git reset --hard HEAD" ) sed_i_arg = "-i" if sys . platform == 'darwin' : sed_i_arg = "-i ''" v6_tag = "" if new_version_int [ 0 ] == 7 : v6_tag = _find_v6_tag ( ctx , new_version ) if v6_tag : ctx . run ( f"sed {sed_i_arg} -E 's#^{new_version}#{new_version} / {v6_tag}#' /tmp/new_changelog.rst" ) ctx . run ( f"sed {sed_i_arg} -e '1,4d' CHANGELOG.rst" ) ctx . run ( "cat CHANGELOG.rst >> /tmp/new_changelog.rst && mv /tmp/new_changelog.rst CHANGELOG.rst" ) ctx . run ( "git add CHANGELOG.rst" ) print ( "\nCommit this with:" ) print ( f"git commit -m \"[DCA] Update CHANGELOG for {new_version}\"" )
Quick task to generate the new CHANGELOG using reno when releasing a minor
version (linux/macOS only).
Quick task to generate the new CHANGELOG using reno when releasing a minor version ( linux / macOS only ) .
"""
    Quick task to generate the new CHANGELOG using reno when releasing a minor
    version (linux/macOS only).
    """ # let's avoid losing uncommitted change with 'git reset --hard' # make sure we are up to date # let's check that the tag for the new version is present (needed by reno) # removing releasenotes from bugfix on the old minor. # 7.15 is the first release in the 7.x series # generate the new changelog # reseting git # mac's `sed` has a different syntax for the "-i" paramter # check whether there is a v6 tag on the same v7 tag, if so add the v6 tag to the release title # remove the old header from the existing changelog # merging to CHANGELOG.rst # commit new CHANGELOG
ctx
new_version