mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 01:30:20 +00:00
On dev versions, choose the latest available release notes file
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
parent
a020f3993d
commit
4548b57365
1 changed files with 23 additions and 20 deletions
|
@ -303,11 +303,18 @@ def update_release_notes(
|
||||||
salt_version = _get_salt_version(ctx)
|
salt_version = _get_salt_version(ctx)
|
||||||
changes = _get_changelog_contents(ctx, salt_version)
|
changes = _get_changelog_contents(ctx, salt_version)
|
||||||
changes = "\n".join(changes.split("\n")[2:])
|
changes = "\n".join(changes.split("\n")[2:])
|
||||||
release_notes_path = "doc/topics/releases/{}.md".format(
|
if salt_version.local:
|
||||||
".".join(str(part) for part in salt_version.release)
|
# This is a dev release, let's pick up the latest changelog file
|
||||||
)
|
versions = {}
|
||||||
if not os.path.exists(release_notes_path):
|
for fpath in pathlib.Path("doc/topics/releases").glob("*.md"):
|
||||||
pathlib.Path(release_notes_path).write_text(
|
versions[(Version(fpath.stem))] = fpath
|
||||||
|
release_notes_path = versions[sorted(versions)[-1]]
|
||||||
|
else:
|
||||||
|
release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format(
|
||||||
|
".".join(str(part) for part in salt_version.release)
|
||||||
|
)
|
||||||
|
if not release_notes_path.exists():
|
||||||
|
release_notes_path.write_text(
|
||||||
textwrap.dedent(
|
textwrap.dedent(
|
||||||
f"""\
|
f"""\
|
||||||
(release-{salt_version})=
|
(release-{salt_version})=
|
||||||
|
@ -315,28 +322,24 @@ def update_release_notes(
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
ctx.run("git", "add", release_notes_path)
|
ctx.run("git", "add", str(release_notes_path))
|
||||||
ctx.info(f"Created bare {release_notes_path} release notes file")
|
ctx.info(f"Created bare {release_notes_path} release notes file")
|
||||||
|
|
||||||
with open(release_notes_path) as rfp:
|
existing = release_notes_path.read_text()
|
||||||
existing = rfp.read()
|
|
||||||
|
|
||||||
if release is True:
|
if release is True:
|
||||||
existing = existing.replace(" - UNRELEASED", "")
|
existing = existing.replace(" - UNRELEASED", "")
|
||||||
|
|
||||||
tmp_release_notes_path = f"{release_notes_path}.tmp"
|
tmp_release_notes_path = (
|
||||||
with open(tmp_release_notes_path, "w") as wfp:
|
release_notes_path.parent / f"{release_notes_path.name}.tmp"
|
||||||
wfp.write(existing)
|
)
|
||||||
wfp.write("\n## Changelog\n")
|
tmp_release_notes_path.write_text(f"{existing}\n## Changelog\n{changes}")
|
||||||
wfp.write(changes)
|
|
||||||
try:
|
try:
|
||||||
with open(tmp_release_notes_path) as rfp:
|
contents = tmp_release_notes_path.read_text().strip()
|
||||||
contents = rfp.read().strip()
|
if draft:
|
||||||
if draft:
|
ctx.print(contents, soft_wrap=True)
|
||||||
ctx.print(contents, soft_wrap=True)
|
else:
|
||||||
else:
|
release_notes_path.write_text(contents)
|
||||||
with open(release_notes_path, "w") as wfp:
|
|
||||||
wfp.write(contents)
|
|
||||||
finally:
|
finally:
|
||||||
os.remove(tmp_release_notes_path)
|
os.remove(tmp_release_notes_path)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue