tasks/release.py
def update_dca_changelog(ctx, new_version, agent_version):
    """
    Quick task to generate the new CHANGELOG-DCA 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)

    agent_version_int = list(map(int, agent_version.split(".")))

    if len(agent_version_int) != 3:
        print(f"Error: invalid version: {agent_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 changes, please commit or stash before using update-dca-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 dca-{new_version}")
    except Failure:
        print(f"Missing 'dca-{new_version}' git tag: mandatory to use 'reno'")
        raise

    # Cluster agent minor releases are in sync with the agent's, bugfixes are not necessarily.
    # We rely on the agent's devel tag to enforce the sync between both releases.
    branching_point_agent = f"{agent_version_int[0]}.{agent_version_int[1]}.0-devel"
    previous_minor_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1] - 1}.X"
    log_result = ctx.run(
        f"git log {branching_point_agent}...remotes/origin/{previous_minor_branchoff} --name-only --oneline |             grep releasenotes-dca/notes/ || true"
    )
    log_result = log_result.stdout.replace('\n', ' ').strip()

    # Do not include release notes that were added in the previous minor release branch (previous_minor_branchoff)
    # and the branch-off points for the current release (pined by the agent's devel tag)
    if len(log_result) > 0:
        ctx.run(f"git rm --ignore-unmatch {log_result}")

    current_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1]}.X"
    # generate the new changelog. Specifying branch in case this is run outside the release branch that contains the tag.
    ctx.run(
        f"reno --rel-notes-dir releasenotes-dca report             --ignore-cache             --branch {current_branchoff}             --version dca-{new_version}             --no-show-source > /tmp/new_changelog-dca.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 ''"
    # remove the old header from the existing changelog
    ctx.run(f"sed {sed_i_arg} -e '1,4d' CHANGELOG-DCA.rst")

    if sys.platform != 'darwin':
        # sed on darwin doesn't support `-z`. On mac, you will need to manually update the following.
        ctx.run(
            "sed -z {0} -e 's/dca-{1}\\n===={2}/{1}\\n{2}/' /tmp/new_changelog-dca.rst".format(  # noqa: FS002
                sed_i_arg, new_version, '=' * len(new_version)
            )
        )

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

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

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

    Quick task to generate the new CHANGELOG-DCA using reno when releasing a minor
    version (linux/macOS only).
    
Quick task to generate the new CHANGELOG-DCA using reno when releasing a minor
version (linux/macOS only).
Quick task to generate the new CHANGELOG - DCA using reno when releasing a minor version ( linux / macOS only ) .
def update_dca_changelog(ctx, new_version, agent_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)
    agent_version_int = list(map(int, agent_version.split(".")))
    if len(agent_version_int) != 3:
        print(f"Error: invalid version: {agent_version_int}")
        raise Exit(1)
    try:
        ctx.run("git diff --exit-code HEAD", hide="both")
    except Failure:
        print("Error: You have uncommitted changes, please commit or stash before using update-dca-changelog")
        return
    ctx.run("git fetch")
    try:
        ctx.run(f"git tag --list | grep dca-{new_version}")
    except Failure:
        print(f"Missing 'dca-{new_version}' git tag: mandatory to use 'reno'")
        raise
    branching_point_agent = f"{agent_version_int[0]}.{agent_version_int[1]}.0-devel"
    previous_minor_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1] - 1}.X"
    log_result = ctx.run(
        f"git log {branching_point_agent}...remotes/origin/{previous_minor_branchoff} --name-only --oneline |             grep releasenotes-dca/notes/ || true"
    )
    log_result = log_result.stdout.replace('\n', ' ').strip()
    if len(log_result) > 0:
        ctx.run(f"git rm --ignore-unmatch {log_result}")
    current_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1]}.X"
    ctx.run(
        f"reno --rel-notes-dir releasenotes-dca report             --ignore-cache             --branch {current_branchoff}             --version dca-{new_version}             --no-show-source > /tmp/new_changelog-dca.rst"
    )
    ctx.run("git reset --hard HEAD")
    sed_i_arg = "-i"
    if sys.platform == 'darwin':
        sed_i_arg = "-i ''"
    ctx.run(f"sed {sed_i_arg} -e '1,4d' CHANGELOG-DCA.rst")
    if sys.platform != 'darwin':
        ctx.run(
            "sed -z {0} -e 's/dca-{1}\\n===={2}/{1}\\n{2}/' /tmp/new_changelog-dca.rst".format(  
                sed_i_arg, new_version, '=' * len(new_version)
            )
        )
    ctx.run("cat CHANGELOG-DCA.rst >> /tmp/new_changelog-dca.rst && mv /tmp/new_changelog-dca.rst CHANGELOG-DCA.rst")
    ctx.run("git add CHANGELOG-DCA.rst")
    print("\nCommit this with:")
    print(f"git commit -m \"[DCA] Update CHANGELOG for {new_version}\"")
def update_dca_changelog ( ctx , new_version , agent_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 ) agent_version_int = list ( map ( int , agent_version . split ( "." ) ) ) if len ( agent_version_int ) != 3 : print ( f"Error: invalid version: {agent_version_int}" ) raise Exit ( 1 ) try : ctx . run ( "git diff --exit-code HEAD" , hide = "both" ) except Failure : print ( "Error: You have uncommitted changes, please commit or stash before using update-dca-changelog" ) return ctx . run ( "git fetch" ) try : ctx . run ( f"git tag --list | grep dca-{new_version}" ) except Failure : print ( f"Missing 'dca-{new_version}' git tag: mandatory to use 'reno'" ) raise branching_point_agent = f"{agent_version_int[0]}.{agent_version_int[1]}.0-devel" previous_minor_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1] - 1}.X" log_result = ctx . run ( f"git log {branching_point_agent}...remotes/origin/{previous_minor_branchoff} --name-only --oneline |             grep releasenotes-dca/notes/ || true" ) log_result = log_result . stdout . replace ( '\n' , ' ' ) . strip ( ) if len ( log_result ) > 0 : ctx . run ( f"git rm --ignore-unmatch {log_result}" ) current_branchoff = f"dca-{new_version_int[0]}.{new_version_int[1]}.X" ctx . run ( f"reno --rel-notes-dir releasenotes-dca report             --ignore-cache             --branch {current_branchoff}             --version dca-{new_version}             --no-show-source > /tmp/new_changelog-dca.rst" ) ctx . run ( "git reset --hard HEAD" ) sed_i_arg = "-i" if sys . platform == 'darwin' : sed_i_arg = "-i ''" ctx . run ( f"sed {sed_i_arg} -e '1,4d' CHANGELOG-DCA.rst" ) if sys . platform != 'darwin' : ctx . run ( "sed -z {0} -e 's/dca-{1}\\n===={2}/{1}\\n{2}/' /tmp/new_changelog-dca.rst" . format ( sed_i_arg , new_version , '=' * len ( new_version ) ) ) ctx . run ( "cat CHANGELOG-DCA.rst >> /tmp/new_changelog-dca.rst && mv /tmp/new_changelog-dca.rst CHANGELOG-DCA.rst" ) ctx . run ( "git add CHANGELOG-DCA.rst" ) print ( "\nCommit this with:" ) print ( f"git commit -m \"[DCA] Update CHANGELOG for {new_version}\"" )
Quick task to generate the new CHANGELOG-DCA using reno when releasing a minor
version (linux/macOS only).
Quick task to generate the new CHANGELOG - DCA using reno when releasing a minor version ( linux / macOS only ) .
"""
    Quick task to generate the new CHANGELOG-DCA 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) # Cluster agent minor releases are in sync with the agent's, bugfixes are not necessarily. # We rely on the agent's devel tag to enforce the sync between both releases. # Do not include release notes that were added in the previous minor release branch (previous_minor_branchoff) # and the branch-off points for the current release (pined by the agent's devel tag) # generate the new changelog. Specifying branch in case this is run outside the release branch that contains the tag. # reseting git # mac's `sed` has a different syntax for the "-i" paramter # remove the old header from the existing changelog # sed on darwin doesn't support `-z`. On mac, you will need to manually update the following. # noqa: FS002 # merging to CHANGELOG.rst # commit new CHANGELOG
ctx
new_version
agent_version