The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(tests): explicit encodings in the parked-branch guard tests
teknium113f105ed15a2
diff --git a/tests/hermes_cli/test_update_parked_branch_guard.py b/tests/hermes_cli/test_update_parked_branch_guard.pyindex 6cf1b28c7fe..5d86bcdec10 100644--- a/tests/hermes_cli/test_update_parked_branch_guard.py+++ b/tests/hermes_cli/test_update_parked_branch_guard.py@@ -57,7 +57,7 @@ def repo_pair(tmp_path):_git(origin, "init", "-q", "-b", "main")_git(origin, "config", "user.email", "[email protected]")_git(origin, "config", "user.name", "Test")- (origin / "a.txt").write_text("one\n")+ (origin / "a.txt").write_text("one\n", encoding="utf-8")_git(origin, "add", "a.txt")_git(origin, "commit", "-qm", "c1")@@ -69,9 +69,9 @@ def repo_pair(tmp_path):_git(clone, "checkout", "-qb", "old-feature")# main advances upstream (two commits).- (origin / "a.txt").write_text("two\n")+ (origin / "a.txt").write_text("two\n", encoding="utf-8")_git(origin, "commit", "-aqm", "c2")- (origin / "b.txt").write_text("three\n")+ (origin / "b.txt").write_text("three\n", encoding="utf-8")_git(origin, "add", "b.txt")_git(origin, "commit", "-qm", "c3")@@ -102,7 +102,7 @@ def test_clean_fully_merged_branch_is_safe_to_switch(repo_pair):def test_dirty_tree_blocks_auto_switch(repo_pair):"""Uncommitted changes on the parked branch → do not touch it."""- (repo_pair / "a.txt").write_text("local edit\n")+ (repo_pair / "a.txt").write_text("local edit\n", encoding="utf-8")safe, reason = update_cmd._assess_parked_branch_switch(GIT, repo_pair, "old-feature", "main")@@ -112,7 +112,7 @@ def test_dirty_tree_blocks_auto_switch(repo_pair):def test_untracked_file_blocks_auto_switch(repo_pair):"""Untracked files count as dirty too — they'd ride along on checkout."""- (repo_pair / "scratch.py").write_text("wip\n")+ (repo_pair / "scratch.py").write_text("wip\n", encoding="utf-8")safe, reason = update_cmd._assess_parked_branch_switch(GIT, repo_pair, "old-feature", "main")@@ -126,7 +126,7 @@ def test_unmerged_commits_switch_with_kept_notice(repo_pair):caller prints the loud 'kept' notice. Non-interactive callers (desktopupdate button, gateway /update, cron) depend on this: they cannotresolve a skip."""- (repo_pair / "feature.txt").write_text("unmerged work\n")+ (repo_pair / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(repo_pair, "add", "feature.txt")_git(repo_pair, "commit", "-qm", "feature work")@@ -194,7 +194,7 @@ def _treeless_repo_pair(tmp_path, *, promisor_reachable=False):# file:// (not a plain path) plus allowFilter: a local origin that speaks# the partial-clone protocol, like GitHub does for real tree:0 clones._git(origin, "config", "uploadpack.allowFilter", "true")- (origin / "a.txt").write_text("one\n")+ (origin / "a.txt").write_text("one\n", encoding="utf-8")_git(origin, "add", "a.txt")_git(origin, "commit", "-qm", "c1")@@ -204,9 +204,9 @@ def _treeless_repo_pair(tmp_path, *, promisor_reachable=False):_git(clone, "config", "user.name", "Test")_git(clone, "checkout", "-qb", "old-feature")- (origin / "a.txt").write_text("two\n")+ (origin / "a.txt").write_text("two\n", encoding="utf-8")_git(origin, "commit", "-aqm", "c2")- (origin / "b.txt").write_text("three\n")+ (origin / "b.txt").write_text("three\n", encoding="utf-8")_git(origin, "add", "b.txt")_git(origin, "commit", "-qm", "c3")@@ -242,7 +242,7 @@ def test_treeless_cherry_failure_degrades_to_conservative_unmerged(tmp_path):the target — degrade to the commit-graph count instead of the old"unverifiable" skip (#124767)."""clone = _treeless_repo_pair(tmp_path)- (clone / "feature.txt").write_text("unmerged work\n")+ (clone / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(clone, "add", "feature.txt")_git(clone, "commit", "-qm", "feature work")safe, reason = update_cmd._assess_parked_branch_switch(@@ -259,7 +259,7 @@ def test_parked_branch_guard_never_lazy_fetches_from_a_live_promisor(tmp_path):wrote 332 packs / 180 GiB in 7 h on Windows (#131444). The guard must notadd a single pack and settles for the commit-graph count."""clone = _treeless_repo_pair(tmp_path, promisor_reachable=True)- (clone / "feature.txt").write_text("unmerged work\n")+ (clone / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(clone, "add", "feature.txt")_git(clone, "commit", "-qm", "feature work")packs_before = _pack_count(clone)@@ -332,7 +332,7 @@ def test_update_refuses_stopped_rebase_without_moving_head(repo_pair, monkeypatch, capsys):"""A user-owned rebase controls the checkout; update must not switch branches underneath it."""- (repo_pair / "a.txt").write_text("topic\n")+ (repo_pair / "a.txt").write_text("topic\n", encoding="utf-8")_git(repo_pair, "add", "a.txt")_git(repo_pair, "commit", "-qm", "topic")rebase = _git(repo_pair, "rebase", "--merge", "origin/main", check=False)@@ -361,12 +361,12 @@ def test_update_reports_git_am_abort_for_apply_state(repo_pair, monkeypatch, capsys):"""rebase-apply is shared by rebase --apply and git am; recovery advice must match Git's owner."""- (repo_pair / "a.txt").write_text("topic\n")+ (repo_pair / "a.txt").write_text("topic\n", encoding="utf-8")_git(repo_pair, "add", "a.txt")_git(repo_pair, "commit", "-qm", "topic")patch = repo_pair.parent / "upstream.patch"patch.write_text(- _git(repo_pair, "format-patch", "-1", "origin/main~1", "--stdout").stdout+ _git(repo_pair, "format-patch", "-1", "origin/main~1", "--stdout").stdout, encoding="utf-8")applied = _git(repo_pair, "am", str(patch), check=False)assert applied.returncode != 0@@ -393,7 +393,7 @@ def test_update_skips_and_warns_on_dirty_parked_branch("""Tonight's incident shape: parked branch + dirty tree. The update mustNOT print '✓ Code updated!', must warn loudly, and must exit non-zerowith the branch named in the summary."""- (repo_pair / "a.txt").write_text("local edit\n")+ (repo_pair / "a.txt").write_text("local edit\n", encoding="utf-8")_patch_update_flow(monkeypatch, repo_pair)args = SimpleNamespace(branch=None, yes=False, force=False, force_venv=False)@@ -421,7 +421,7 @@ def test_update_switches_unmerged_parked_branch_with_kept_notice(cannot resolve a skip), prints the loud 'kept' notice, ends on mainfast-forwarded to origin/main, and the commits stay on the parkedbranch untouched."""- (repo_pair / "feature.txt").write_text("unmerged work\n")+ (repo_pair / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(repo_pair, "add", "feature.txt")_git(repo_pair, "commit", "-qm", "feature work")feature_sha = _git(repo_pair, "rev-parse", "old-feature").stdout.strip()@@ -472,7 +472,7 @@ def test_update_updates_unmerged_branch_in_place_when_configured("load_config",lambda: {"updates": {"parked_branch_strategy": "update_in_place"}},)- (repo_pair / "feature.txt").write_text("unmerged work\n")+ (repo_pair / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(repo_pair, "add", "feature.txt")_git(repo_pair, "commit", "-qm", "feature work")_patch_update_flow(monkeypatch, repo_pair)@@ -500,9 +500,9 @@ def test_update_updates_unmerged_branch_in_place_when_configured()# origin/main's code actually arrived (b.txt lands with c3)...assert (repo_pair / "b.txt").exists()- assert (repo_pair / "a.txt").read_text() == "two\n"+ assert (repo_pair / "a.txt").read_text(encoding="utf-8-sig") == "two\n"# ...and the branch's own commit survived it.- assert (repo_pair / "feature.txt").read_text() == "unmerged work\n"+ assert (repo_pair / "feature.txt").read_text(encoding="utf-8-sig") == "unmerged work\n"assert "feature work" in _git(repo_pair, "log", "--oneline").stdout@@ -524,7 +524,7 @@ def test_switch_branch_flag_overrides_in_place_strategy("load_config",lambda: {"updates": {"parked_branch_strategy": "update_in_place"}},)- (repo_pair / "feature.txt").write_text("unmerged work\n")+ (repo_pair / "feature.txt").write_text("unmerged work\n", encoding="utf-8")_git(repo_pair, "add", "feature.txt")_git(repo_pair, "commit", "-qm", "feature work")branch_tip_before = _git(@@ -608,7 +608,7 @@ def test_update_up_to_date_path_does_not_repark_merged_branch(tmp_path, monkeypa_git(origin, "init", "-q", "-b", "main")_git(origin, "config", "user.email", "[email protected]")_git(origin, "config", "user.name", "Test")- (origin / "a.txt").write_text("one\n")+ (origin / "a.txt").write_text("one\n", encoding="utf-8")_git(origin, "add", "a.txt")_git(origin, "commit", "-qm", "c1")