Skip to content

fix: tolerate missing origin/main in Hermes setup#35

Merged
Maleick merged 2 commits into
mainfrom
bug/fix-setup-script-denial-of-service-issue
May 11, 2026
Merged

fix: tolerate missing origin/main in Hermes setup#35
Maleick merged 2 commits into
mainfrom
bug/fix-setup-script-denial-of-service-issue

Conversation

@Maleick
Copy link
Copy Markdown
Owner

@Maleick Maleick commented May 11, 2026

Motivation

  • hooks/hermes/setup.sh runs under set -euo pipefail, and the new auto-sync block used git log HEAD..origin/main in an assignment which can exit non-zero and abort setup when origin/main is missing or unavailable.
  • The change aims to improve availability/reliability of Hermes setup so repositories without an origin/main remote-tracking ref still produce a valid runtime config.

Description

  • Update hooks/hermes/setup.sh auto-sync block to guard the git log assignment with an if so a failing git log does not cause the script to exit under set -euo pipefail.
  • Emit a warning and continue with local code when origin/main is unavailable, while preserving the existing git pull origin main behavior when a sync gap is detected.
  • The only modified file is hooks/hermes/setup.sh and the change is minimal and backward-compatible with previous behavior when remotes are present.

Testing

  • Ran ./hooks/hermes/setup.sh in a repo configuration without origin/main and verified it exits 0 and creates .archaeology/hermes-runtime.json (warning printed but setup completes).
  • Performed static checks with bash -n hooks/hermes/setup.sh and bash -n hooks/hermes/*.sh which succeeded.
  • Ran the full verification bash hooks/opencode/verify-phase.sh final_verify which runs npm test and npx tsc --noEmit, and all automated tests passed (38 tests, 0 failures) and typecheck passed.
  • Ran git diff --check and other repository script validations which reported no issues.

Codex Task

Copilot AI review requested due to automatic review settings May 11, 2026 02:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves the robustness of the Hermes setup hook by preventing set -euo pipefail from aborting setup when origin/main is missing/unavailable during the auto-sync check, so Hermes can still generate a runtime config in repos without that remote-tracking ref.

Changes:

  • Wraps the git log HEAD..origin/main sync-gap computation in an if so failures don’t terminate the script under set -e.
  • Emits a warning and continues with local code when origin/main can’t be queried, while preserving the existing pull behavior when a sync gap is detected.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/hermes/setup.sh Outdated
Comment on lines +13 to +16
if sync_gap=$(git log --oneline HEAD..origin/main 2>/dev/null | wc -l | tr -d ' '); then
if [[ "$sync_gap" =~ ^[0-9]+$ && "$sync_gap" -gt 0 ]]; then
echo "[code-archaeology-sync] $sync_gap commit(s) behind origin/main — pulling..."
git pull origin main >/dev/null 2>&1 || echo "[code-archaeology-sync] WARN: git pull failed, continuing with local code"
@Maleick Maleick force-pushed the bug/fix-setup-script-denial-of-service-issue branch from 9805a6c to c515271 Compare May 11, 2026 03:15
@Maleick Maleick force-pushed the bug/fix-setup-script-denial-of-service-issue branch from c515271 to 6d76a20 Compare May 11, 2026 03:19
@Maleick Maleick merged commit 60744fb into main May 11, 2026
1 check passed
@Maleick Maleick deleted the bug/fix-setup-script-denial-of-service-issue branch May 11, 2026 04:08
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants