MCPcopy
hub / github.com/saltstack/salt / update_release_notes

Function update_release_notes

tools/changelog.py:210–302  ·  view source on GitHub ↗
(
    ctx: Context,
    salt_version: Version,
    draft: bool = False,
    release: bool = False,
    template_only: bool = False,
    next_release: bool = False,
)

Source from the content-addressed store, hash-verified

208 },
209)
210def update_release_notes(
211 ctx: Context,
212 salt_version: Version,
213 draft: bool = False,
214 release: bool = False,
215 template_only: bool = False,
216 next_release: bool = False,
217):
218 if salt_version is None:
219 salt_version = _get_salt_version(ctx, next_release=next_release)
220 changes = _get_changelog_contents(ctx, salt_version)
221 changes = "\n".join(changes.split("\n")[2:])
222 if salt_version.local:
223 # This is a dev release, let's pick up the latest changelog file
224 versions = {}
225 for fpath in pathlib.Path("doc/topics/releases").glob("*.md"):
226 versions[(Version(fpath.stem))] = fpath
227 latest_version = sorted(versions)[-1]
228 release_notes_path = versions[latest_version]
229 version = ".".join(str(part) for part in latest_version.release)
230 else:
231 version = ".".join(str(part) for part in salt_version.release)
232 release_notes_path = pathlib.Path("doc/topics/releases") / "{}.md".format(
233 version
234 )
235
236 template_release_path = (
237 release_notes_path.parent / "templates" / f"{version}.md.template"
238 )
239 if not template_release_path.exists():
240 template_release_path.write_text(
241 textwrap.dedent(
242 f"""\
243 (release-{salt_version})=
244 # Salt {salt_version} release notes{{{{ unreleased }}}}
245 {{{{ warning }}}}
246
247 <!--
248 Add release specific details below
249 -->
250
251 <!--
252 Do not edit the changelog below.
253 This is auto generated.
254 -->
255 ## Changelog
256 {{{{ changelog }}}}
257 """
258 )
259 )
260 ctx.run("git", "add", str(template_release_path))
261 ctx.info(f"Created template {template_release_path} release notes file")
262 if template_only:
263 # Only generate the template for a new release
264 return
265
266 unreleased = " - UNRELEASED"
267 warning = """

Callers

nothing calls this directly

Calls 11

VersionClass · 0.90
_get_salt_versionFunction · 0.85
_get_changelog_contentsFunction · 0.85
formatMethod · 0.80
existsMethod · 0.45
runMethod · 0.45
infoMethod · 0.45
get_templateMethod · 0.45
renderMethod · 0.45
read_textMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected