Files
actual/scripts
Matiss Janis Aboltins e6811e8ddf [AI] Fix git-guard false positives on heredoc and multi -m commit messages (#8192)
* [AI] Fix git-guard false positives on heredoc and multi -m commits

The [AI]-prefix check extracted the commit message with a greedy
".*-m" sed pattern, which broke in two real-world cases:

- "git commit -m \"$(cat <<'EOF' ...)\"" — the pattern matched the
  command-substitution text on the first line and reported the message
  as "$(cat <<", blocking a correctly prefixed commit.
- Multiple -m flags — the greedy match grabbed the LAST -m (typically
  a Co-Authored-By trailer), so valid commits were blocked and a
  missing prefix on the subject could slip through if the last
  paragraph happened to start with [AI].

Replace the extraction: find the FIRST -m/--message via
shortest-prefix stripping (git takes the first -m as the subject),
detect the heredoc-in-command-substitution form and read the subject
from the heredoc body's first line, and otherwise check the inline
string as before. Editor/amend/file-based commits remain untouched,
as do the push, hook-skip, git-config and yarn-workspace guards.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* [AI] Add release notes

* [AI] Fail closed when heredoc detector matches without a body line

The heredoc pattern also matches single-line command substitutions
containing a here-string (e.g. <<< on one line), where reading the
"second line" produced an empty message that the final check treated
as "no inline message" and allowed — letting unprefixed subjects
through. Take the first non-blank heredoc body line instead (matching
git's leading-blank-line cleanup), and when no body line exists fall
back to inline parsing so a statically unknowable message is blocked
rather than waved through.

Found by CodeRabbit review on #8192.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 22:23:26 +00:00
..