jesseduffield.lazygit/scripts/check_for_fixups.sh
Stefan Haller 58309b02a9 Fix the check_for_fixups script
Git's --grep option uses Basic Regular Expression syntax by default, which means
that the `[^\n]*` didn't do what was intended; it means "any character except
`\` or the literal letter `n`" — not "any character except newline."

Besides, `^` matched any line start, not only the start of the entire message,
so "any character except newline" would have been wrong anyway. Given this, the
script matched commits that have WIP or DROPME in the body, which is not what we
want. (The last commit of this branch is an example for that.)

Fix this by listing only the subject lines and grepping them outside of git;
this also lets us use a slightly simpler regex (we want to match WIP anywhere in
the subject).
2026-04-21 18:51:17 +02:00

15 lines
353 B
Bash
Executable file

#!/bin/sh
# We will have only done a shallow clone, so the git log will consist only of
# commits on the current PR
commits=$(git log --format="%h %s" | egrep '(^fixup!|^squash!|^amend!|WIP|DROPME)')
if [ -z "$commits" ]; then
echo "No fixup commits found."
exit 0
else
echo "Fixup or WIP commits found:"
echo "$commits"
exit 1
fi