The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(install-e2e): follow staged main with explicit source branch
ethernetdd744286edc0
diff --git a/tests/install/e2e-assets/source-update-command.sh b/tests/install/e2e-assets/source-update-command.shnew file mode 100644index 00000000000..c670407e40d--- /dev/null+++ b/tests/install/e2e-assets/source-update-command.sh@@ -0,0 +1,16 @@+#!/usr/bin/env bash+# Build the installed CLI's invocation for a source-to-source update.+# Older releases do not accept either flag, so probe their own help first.+build_source_update_command() {+ local hermes="$1" help="$2"+ update_cmd=("$hermes" update)+ if grep -qF -- --yes <<< "$help"; then+ update_cmd+=(--yes)+ fi+ # This fixture advances serve.git/main to an unpublished HEAD (or NEXT).+ # Newer updaters otherwise consult releases/channels/main.json, which may+ # not exist. Explicit --branch main follows the fixture's git transport.+ if grep -Eq -- '(^|[[:space:]]|\[)--branch([=[:space:]]|$)' <<< "$help"; then+ update_cmd+=(--branch main)+ fi+}diff --git a/tests/install/installer-script-e2e.sh b/tests/install/installer-script-e2e.shindex efca303714e..478a41a6435 100755--- a/tests/install/installer-script-e2e.sh+++ b/tests/install/installer-script-e2e.sh@@ -115,6 +115,8 @@ source "$(dirname "$0")/e2e-assets/mock-provider.sh"source "$(dirname "$0")/e2e-assets/source-driver.sh"# shellcheck source=e2e-assets/installer-common.shsource "$(dirname "$0")/e2e-assets/installer-common.sh"+# shellcheck source=e2e-assets/source-update-command.sh+source "$(dirname "$0")/e2e-assets/source-update-command.sh"# shellcheck source=e2e-assets/source-build-env.shsource "$ASSETS/source-build-env.sh"# Full transcript in the job log, collapsed (GitHub renders ::group:: as a@@ -425,11 +427,7 @@ case "$UPDATE_METHOD" in# installed hermes; older ones read the prompt from stdin, so close it.HERMES="$(source_hermes "$INSTALL_DIR")" || fail "no installed update command"help="$(source_build_env "$HERMES" update --help 2>&1)" || fail "installed update --help failed: $help"- if grep -qF -- --yes <<< "$help"; then- update_cmd=("$HERMES" update --yes)- else- update_cmd=("$HERMES" update)- fi+ build_source_update_command "$HERMES" "$help"rc=0(cd "$INSTALL_DIR" && source_build_env "${update_cmd[@]}" < /dev/null 2>&1 | ts_prefix > "$LOG_DIR/update.log") || rc=$?log_group "hermes update transcript" "$LOG_DIR/update.log"diff --git a/tests/scripts/test_source_update_command.py b/tests/scripts/test_source_update_command.pynew file mode 100644index 00000000000..c7fe279cd89--- /dev/null+++ b/tests/scripts/test_source_update_command.py@@ -0,0 +1,44 @@+"""Source E2E updates must follow the staged git branch when supported."""++import os+from pathlib import Path+import subprocess++import pytest+++HELPER = Path(__file__).resolve().parents[1] / "install/e2e-assets/source-update-command.sh"++[email protected]("posix")+ ("help_text", "expected"),+ [+ ("update [--yes] [--branch NAME]", "update --yes --branch main"),+ ("update [--yes]", "update --yes"),+ ("update [--switch-branch]", "update"),+ ("update", "update"),+ ],+)+def test_source_update_follows_staged_main_if_installed_cli_accepts_branch(tmp_path, help_text, expected):+ cli = tmp_path / "installed hermes"+ cli.write_text('''#!/usr/bin/env bash+if [[ "$*" == *"--branch main"* ]]; then+ printf 'selected staged main: %s\\n' "$*"+elif [[ "$EXPECT_BRANCH" == 1 ]]; then+ printf 'Channel object not found: releases/channels/main.json\\n' >&2+ exit 1+else+ printf 'legacy updater: %s\\n' "$*"+fi+''', encoding="utf-8")+ cli.chmod(0o755)+ result = subprocess.run(+ ["bash", "-euc", 'source "$HELPER"; build_source_update_command "$CLI" "$HELP_TEXT"; "${update_cmd[@]}"'],+ env=dict(os.environ, HELPER=str(HELPER), CLI=str(cli), HELP_TEXT=help_text,+ EXPECT_BRANCH="1" if "--branch NAME" in help_text else "0"),+ capture_output=True, text=True, timeout=30,+ )+ assert result.returncode == 0, result.stderr+ assert result.stdout.strip().endswith(expected)+ assert "Channel object not found" not in result.stderr