diff options
| -rwxr-xr-x | .extras/hooks/pre-commit | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/.extras/hooks/pre-commit b/.extras/hooks/pre-commit index d2f9506..7158125 100755 --- a/.extras/hooks/pre-commit +++ b/.extras/hooks/pre-commit @@ -72,7 +72,22 @@ if [ "${SBOLINT:-yes}" = "yes" ]; then if [ -e "$build/slack-desc" -o -e "$build/README" ]; then sbolint "$build" || sbolintfailed=1 fi - done < <(git diff --cached --name-only | cut -d/ -f1,2 | sort -u) + done < <(git diff --cached --name-only | while IFS= read -r f; do + # Walk up from the changed file to the directory that holds + # the .SlackBuild: that's the build dir sbolint wants. Depth + # isn't assumed, so this works for both a flat layout + # (<pkg>/) and SBo's own (<category>/<pkg>/). Root-level + # files (CLAUDE.md, .extras/...) walk up to "." and are + # dropped, they aren't builds. + d=$(dirname "$f") + while [ "$d" != "." ] && [ "$d" != "/" ]; do + if compgen -G "$d/*.SlackBuild" >/dev/null; then + printf '%s\n' "$d" + break + fi + d=$(dirname "$d") + done + done | sort -u) fi if [ -n "$sbolintfailed" ]; then echo "*** sbolint failed, fix the errors or set SBOLINT=no" |
