fix(update): switch to main before pulling local-only branches#3467
fix(update): switch to main before pulling local-only branches#3467SollanSystems wants to merge 1 commit intoNousResearch:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes hermes update failures when run from a local-only git branch by ensuring the update pull happens from the correct checked-out branch, and adds regression tests around branch switching and autostash restoration behavior.
Changes:
- Track
current_branchseparately from the update target branch incmd_update. - When the current branch is not present on
origin,checkout mainbeforegit pull --ff-only origin main. - Ensure autostashed changes are restored even if the fallback checkout fails; add regression tests for these behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
hermes_cli/main.py |
Separates current vs target branch and checks out the target branch (e.g., main) before pulling to avoid FF-only failures from local-only branches. |
tests/hermes_cli/test_cmd_update.py |
Adds regression tests verifying checkout happens before pull on fallback, and that stashed changes are restored even when checkout fails. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| mock_restore.assert_called_once_with( | ||
| ["git"], | ||
| PROJECT_ROOT, | ||
| "stash123", | ||
| prompt_user=False, | ||
| ) |
There was a problem hiding this comment.
This assertion hard-codes git_cmd as ["git"], but cmd_update uses a platform-dependent git_cmd (on Windows it becomes ["git", "-c", "windows.appendAtomically=false"]). Consider asserting the git_cmd argument more flexibly (e.g., match the prefix, or derive the expected value from sys.platform) so the test remains portable if run on Windows.
|
Thanks for the fix! This was independently addressed in PR #3492 (merged March 27), which did a broader hardening of |
Summary
current_branchseparate from the update target branch incmd_updategit checkout mainbeforegit pull --ff-only origin mainProblem
Updating from a local-only branch could fall back to
mainlogically, but still attempt to fast-forward from the local branch context. That leads to update failures like:Test Plan
uv run --extra dev pytest -o addopts= tests/hermes_cli/test_cmd_update.py tests/hermes_cli/test_update_autostash.py tests/hermes_cli/test_update_gateway_restart.py tests/hermes_cli/test_update_check.py -q