mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-07 14:06:42 +02:00
fix: pre-landing review auto-fixes (5 correctness + observability)
/ship Step 9 review surfaced 9 INFORMATIONAL findings on the new helper +
migration. Five auto-fixed with no behavior regression (26/26 tests pass):
bin/gstack-gbrain-source-wireup:
- Version compare: put floor "0.18.0" first in `sort -V` stdin so equal-or-
greater $v always sorts to position 2. Stable across sort implementations.
- _worktree_add_detached: drop `2>/dev/null` on the `worktree add`, surface
git's stderr through `prefix` so users see WHY adds fail (disk, perms).
- ensure_worktree: same observability fix on the `git checkout --detach` path
during HEAD-advance, so users see the actual git error before recovery.
- do_probe: replace `[ -d X ] || [ -f X ] && set=present` (precedence trap —
the `&&` short-circuits when the dir branch fails) with explicit if-block.
- do_probe: capture `check_source_state`'s return code explicitly via
`set +e; ...; rc=$?; set -e`. `$?` after an `if`/`elif` chain is fragile
under set -e and may not reach the elif under some shell versions.
- do_wireup: same explicit return-code capture for `ensure_worktree`. The
prior `ensure_worktree || { if [ $? = 2 ]; ...` pattern relied on `$?`
reflecting the function's return after `||`, which is implementation-defined.
gstack-upgrade/migrations/v1.15.1.0.sh:
- Trim whitespace from `gstack-config get gbrain_sync_mode` output via
`tr -d '[:space:]'`. Trailing newlines would mis-classify "off\n" as a
non-empty non-off mode and incorrectly invoke the helper.
Skipped findings (cosmetic / out of scope):
- `python3 -c` reads `~/.gbrain/config.json` via `expanduser` instead of
the helper's `$GBRAIN_CONFIG` variable (cosmetic; HONORS HOME override).
- Long sync-failure error message could truncate to last N lines (cosmetic
log readability).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,9 @@ WIREUP_BIN="${BIN_DIR}/gstack-gbrain-source-wireup"
|
||||
# Skip if user never opted into brain-sync.
|
||||
SYNC_MODE=""
|
||||
if [ -x "$CONFIG_BIN" ]; then
|
||||
SYNC_MODE=$("$CONFIG_BIN" get gbrain_sync_mode 2>/dev/null || echo "")
|
||||
# Trim whitespace defensively: gstack-config can emit trailing newlines,
|
||||
# which would mis-classify "off\n" as a non-empty non-off mode.
|
||||
SYNC_MODE=$("$CONFIG_BIN" get gbrain_sync_mode 2>/dev/null | tr -d '[:space:]' || echo "")
|
||||
fi
|
||||
if [ "$SYNC_MODE" = "off" ] || [ -z "$SYNC_MODE" ]; then
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user