mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(cli): fall back to main when current branch has no remote counterpart
`hermes update` crashed with CalledProcessError when run on a local-only
branch (e.g. fix/stoicneko) because `git rev-list HEAD..origin/{branch}`
fails when origin/{branch} doesn't exist. Now verifies the remote branch
exists first and falls back to origin/main.
This commit is contained in:
parent
a748257bf5
commit
e1824ef8a6
2 changed files with 116 additions and 1 deletions
|
|
@ -2056,7 +2056,15 @@ def cmd_update(args):
|
|||
check=True
|
||||
)
|
||||
branch = result.stdout.strip()
|
||||
|
||||
|
||||
# Fall back to main if the current branch doesn't exist on the remote
|
||||
verify = subprocess.run(
|
||||
git_cmd + ["rev-parse", "--verify", f"origin/{branch}"],
|
||||
cwd=PROJECT_ROOT, capture_output=True, text=True,
|
||||
)
|
||||
if verify.returncode != 0:
|
||||
branch = "main"
|
||||
|
||||
# Check if there are updates
|
||||
result = subprocess.run(
|
||||
git_cmd + ["rev-list", f"HEAD..origin/{branch}", "--count"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue