From 694e77e1c0f1190ffb586791567513d25e26bfa3 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sat, 13 Jun 2026 08:17:31 +0100 Subject: [PATCH] Wrap stop hook lgtm output - Keep Stop hook stdout valid JSON so Codex can parse it. - Move `./bin/brew lgtm` handling into a wrapper script. --- .codex/hooks.json | 2 +- .codex/hooks/brew-lgtm-stop.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 .codex/hooks/brew-lgtm-stop.sh diff --git a/.codex/hooks.json b/.codex/hooks.json index 5374b0e628..8baaa5a8e2 100644 --- a/.codex/hooks.json +++ b/.codex/hooks.json @@ -5,7 +5,7 @@ "hooks": [ { "type": "command", - "command": "./bin/brew lgtm >&2 && printf '{\"continue\":true}'", + "command": ".codex/hooks/brew-lgtm-stop.sh", "timeout": 360 } ] diff --git a/.codex/hooks/brew-lgtm-stop.sh b/.codex/hooks/brew-lgtm-stop.sh new file mode 100755 index 0000000000..9bc8522484 --- /dev/null +++ b/.codex/hooks/brew-lgtm-stop.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +cd "$(dirname "$0")/../.." || { + printf '%s\n' '{"decision":"block","reason":"Failed to cd to the repository root before running ./bin/brew lgtm."}' + exit 0 +} + +if ./bin/brew lgtm >&2 +then + printf '%s\n' '{"continue":true}' +else + printf '%s\n' '{"decision":"block","reason":"./bin/brew lgtm failed; review the output above and fix it before stopping."}' +fi