The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(release): add a changelog subcommand and point oversized drafts at it
ethernetcc1679d44da0
diff --git a/scripts/release.py b/scripts/release.pyindex 703c1a0e935..4bce7501067 100755--- a/scripts/release.py+++ b/scripts/release.py@@ -658,6 +658,12 @@ def main():release_cmd.add_argument("--no-changelog", action="store_true", default=argparse.SUPPRESS,help="Leave the commit list out of the draft body")release_cmd.add_argument("--remote", type=str)+ changelog_cmd = subcommands.add_parser(+ "changelog", help="Print the changelog the next stable release draft would carry")+ changelog_cmd.add_argument("--commit", required=True, metavar="SHA",+ help="Commit the release would be cut at")+ changelog_cmd.add_argument("--bump", choices=["major", "minor", "patch"], default="patch")+ changelog_cmd.add_argument("--remote", type=str)publish_cmd = subcommands.add_parser("publish", help="Publish a green stable release through the ordered sequencer")publish_cmd.add_argument("--version", required=True)@@ -671,9 +677,10 @@ def main():add_arguments(parser)args = parser.parse_args()- from scripts.releases.entrypoint import cmd_abandon, cmd_publish, cmd_release+ from scripts.releases.entrypoint import cmd_abandon, cmd_changelog, cmd_publish, cmd_release- stable_commands = {"release": cmd_release, "publish": cmd_publish, "abandon": cmd_abandon}+ stable_commands = {"release": cmd_release, "publish": cmd_publish, "abandon": cmd_abandon,+ "changelog": cmd_changelog}if args.command:stable_commands[args.command](args)return@@ -700,7 +707,7 @@ def main():if selected:handler(args)return- parser.error("select release, publish, abandon, --canary, --build-commit, or a channel operation")+ parser.error("select release, publish, abandon, changelog, --canary, --build-commit, or a channel operation")if __name__ == "__main__":diff --git a/scripts/releases/entrypoint.py b/scripts/releases/entrypoint.pyindex b232983f19e..cac2b2add97 100644--- a/scripts/releases/entrypoint.py+++ b/scripts/releases/entrypoint.py@@ -229,7 +229,13 @@ def release(commit: str, *, bump: str, repo: Path, remote: str, repository: str,if len(body) > GITHUB_BODY_LIMIT:raise ReleaseRefused(f"the {tag} draft body is {len(body)} characters; GitHub accepts at most "- f"{GITHUB_BODY_LIMIT}. Nothing was claimed. Re-run with --no-changelog.")+ f"{GITHUB_BODY_LIMIT}. Nothing was claimed.\n"+ "Write the changelog by hand, in this order:\n"+ f" 1. python scripts/release.py changelog --commit {commit} --bump {bump} "+ f"--remote {remote} > changelog.md\n"+ " Do this before step 2: once the retry claims this attempt, changelog numbers the next one.\n"+ " 2. Re-run the same release command with --no-changelog.\n"+ " 3. Edit changelog.md down in your editor and paste it into the draft release body.")claim_epoch = _next_claim_epoch(repo, claims)claim = json.dumps({"schema": 1,@@ -496,6 +502,19 @@ def cmd_release(args) -> None:print(next_steps(result, bold=sys.stdout.isatty() and "NO_COLOR" not in os.environ))+def cmd_changelog(args) -> None:+ """The ``changelog`` subcommand: print the notes the next draft would carry, claiming nothing."""+ from scripts.releases.versioning import published_stable_identity++ repo, remote, repository = _command_repository(args)+ commit = _git(repo, "rev-parse", "--verify", f"{args.commit}^{{commit}}")+ published = published_stable_identity(repository)+ version = derive_next_version(published=published[0], bump=args.bump)+ tag = attempt_ref(version, next_attempt(version, _claims(repo, remote)))+ print(_changelog(repo, repository, commit=commit, tag=tag, version=version,+ published=published, no_changelog=False))++def _command_repository(args) -> tuple[Path, str, str]:from scripts import release as release_scriptdiff --git a/tests/scripts/test_release_entrypoint.py b/tests/scripts/test_release_entrypoint.pyindex 90f9dd44725..364e2d97908 100644--- a/tests/scripts/test_release_entrypoint.py+++ b/tests/scripts/test_release_entrypoint.py@@ -395,13 +395,20 @@ def _oversized_commit(repo, tmp_path):return git(repo, "rev-parse", "HEAD")-def test_an_oversized_body_is_refused_before_the_claim(source, tmp_path):[email protected]("bump", ["patch", "minor", "major"])+def test_an_oversized_body_is_refused_before_the_claim(source, tmp_path, bump):from scripts.releases.entrypoint import ReleaseRefusedcommit = _oversized_commit(source, tmp_path)- with pytest.raises(ReleaseRefused, match="--no-changelog"):- _release(source, commit, execute=lambda command: pytest.fail(f"must not run {command}"))+ with pytest.raises(ReleaseRefused, match="--no-changelog") as refused:+ _release(source, commit, bump=bump, execute=lambda command: pytest.fail(f"must not run {command}"))+ hint = str(refused.value)+ export = f"python scripts/release.py changelog --commit {commit} --bump {bump} --remote origin"+ # The export comes first: after the retry claims this attempt, changelog numbers the next one.+ assert export in hint+ assert hint.index(export) < hint.index("Re-run the same release command with --no-changelog")+ assert "paste it into the draft release body" in hint# Nothing was claimed, so the attempt is not burned.assert git(source, "ls-remote", "origin", "refs/tags/*") == ""@@ -427,6 +434,33 @@ def test_no_changelog_releases_what_the_full_changelog_could_not(source, tmp_patassert "<!-- HERMES_BUILDS_TABLE -->" in seen["body"]+def test_changelog_prints_the_notes_a_draft_would_carry_and_claims_nothing(source, monkeypatch, capsys):+ from scripts import release as release_script+ from scripts.releases import entrypoint++ shipped = _advance(source, "fix: shipped in the published release")+ git(source, "tag", "-a", "v0.21.4", shipped, "-m", "published")+ commit = _advance(source, "feat: new in this release (#123)")+ monkeypatch.setattr(release_script, "REPO_ROOT", source)+ monkeypatch.setattr(release_script, "remote_github_repo", lambda _remote: "example/hermes-agent")+ monkeypatch.setattr("scripts.releases.versioning.published_stable_identity",+ lambda _repository: ("0.21.4", shipped))+ monkeypatch.setattr(release_script.sys, "argv",+ ["release.py", "changelog", "--commit", commit, "--remote", "origin"])++ release_script.main()++ out = capsys.readouterr().out+ assert out.startswith("# Hermes Agent v0.21.5 (rc.1-v0.21.5)")+ assert "New in this release" in out+ assert "hipped in the published release" not in out+ assert git(source, "ls-remote", "origin", "refs/tags/*") == ""+ # The notes name the attempt the --no-changelog retry then claims.+ retried = _release(source, commit, published=("0.21.4", shipped), no_changelog=True)+ assert retried["tag"] == "rc.1-v0.21.5"+ assert "compare/v0.21.4...rc.1-v0.21.5" in out++@pytest.mark.parametrize("argv", [["release", "--commit", "HEAD", "--no-changelog"],["--no-changelog", "release", "--commit", "HEAD"],