The canonical pre-commit hook can exit with status 1 when pyproject.toml is staged but the staged diff does not contain any quoted dependency lines.
This is separate from #3
That issue covers the macOS/BSD sed portability problem where \s leaves the diff marker in the extracted package name. This issue covers the empty-match path under set -euo pipefail
The hook currently builds dependency candidates with a pipeline like:
changed_names=$(git diff --cached -- pyproject.toml \
| grep -E '^[+-]\s*"[A-Za-z0-9][A-Za-z0-9._-]*' \
| sed -E 's/^[+-]\s*"([A-Za-z0-9][A-Za-z0-9._-]*).*/\1/' \
| sort -u)
If pyproject.toml is staged but no dependency-like line matches, grep exits 1
Because the hook uses set -euo pipefail, the command substitution exits before the later empty-result guard can run
proposed fix:
changed_names=$(git diff --cached -- pyproject.toml \
| sed -nE 's/^[+-][[:space:]]*"([A-Za-z0-9][A-Za-z0-9._-]*).*/\1/p' \
| sort -u)
this will also fix #3
The canonical pre-commit hook can exit with status 1 when
pyproject.tomlis staged but the staged diff does not contain any quoted dependency lines.This is separate from #3
That issue covers the macOS/BSD
sedportability problem where\sleaves the diff marker in the extracted package name. This issue covers the empty-match path underset -euo pipefailThe hook currently builds dependency candidates with a pipeline like:
If pyproject.toml is staged but no dependency-like line matches, grep exits 1
Because the hook uses set -euo pipefail, the command substitution exits before the later empty-result guard can run
proposed fix:
this will also fix #3