Skip to content

Commit

Permalink
Do not import salt in tools and add --next-release to version
Browse files Browse the repository at this point in the history
  • Loading branch information
Megan Wilhite committed Apr 5, 2023
1 parent 1e5c703 commit 58481ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions changelog/64023.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add --next-release argument to salt/version.py, which prints the next upcoming release.
2 changes: 1 addition & 1 deletion doc/topics/releases/templates/3007.0.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{ warning }}

<!--
Add relase specific details below
Add release specific details below
-->


Expand Down
15 changes: 14 additions & 1 deletion salt/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Set up the version of Salt
"""
import argparse
import operator
import os
import platform
Expand Down Expand Up @@ -921,5 +922,17 @@ def versions_report(include_salt_cloud=False, include_extensions=True):
yield from info


def _parser():
parser = argparse.ArgumentParser()
parser.add_argument(
"--next-release", help="Return the next release", action="store_true"
)
return parser.parse_args()


if __name__ == "__main__":
print(__version__)
args = _parser()
if args.next_release:
print(__saltstack_version__.next_release())
else:
print(__version__)
18 changes: 6 additions & 12 deletions tools/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from jinja2 import Environment, FileSystemLoader
from ptscripts import Context, command_group

import salt.version
from tools.utils import REPO_ROOT, Version

CHANGELOG_LIKE_RE = re.compile(r"([\d]+)\.([a-z]+)$")
Expand Down Expand Up @@ -176,8 +175,11 @@ def _get_pkg_changelog_contents(ctx: Context, version: Version):
return changes


def _get_salt_version(ctx):
ret = ctx.run("python3", "salt/version.py", capture=True, check=False)
def _get_salt_version(ctx, next_release=False):
args = []
if next_release:
args.append("--next-release")
ret = ctx.run("python3", "salt/version.py", *args, capture=True, check=False)
if ret.returncode:
ctx.error(ret.stderr.decode())
ctx.exit(1)
Expand Down Expand Up @@ -314,7 +316,7 @@ def update_release_notes(
next_release: bool = False,
):
if salt_version is None:
salt_version = _get_salt_version(ctx)
salt_version = _get_salt_version(ctx, next_release=next_release)
changes = _get_changelog_contents(ctx, salt_version)
changes = "\n".join(changes.split("\n")[2:])
if salt_version.local:
Expand All @@ -330,14 +332,6 @@ def update_release_notes(
release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format(
version
)
if next_release and not release:
version = ".".join(
str(part)
for part in salt.version.SaltStackVersion(*version).next_release().info
)
release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format(
version
)

template_release_path = (
release_notes_path.parent / "templates" / f"{version}.md.template"
Expand Down

0 comments on commit 58481ad

Please sign in to comment.