aboutsummaryrefslogtreecommitdiffstats
path: root/.extras
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-08 13:01:07 +0200
committerDanilo M. <danix@danix.xyz>2026-08-08 13:01:07 +0200
commit998dbd56e53c8c8c8bc1a425cec16b6ccc752e34 (patch)
tree644146368bbcf94c986d14df370482b82db3e8eb /.extras
parent78d37fb4f2f09de3900a120e3e11479c19b14d12 (diff)
downloadsbo-slackbuilds-998dbd56e53c8c8c8bc1a425cec16b6ccc752e34.tar.gz
sbo-slackbuilds-998dbd56e53c8c8c8bc1a425cec16b6ccc752e34.zip
hooks: fix pre-commit sbolint never running
The sbolint loop extracted build dirs with "cut -d/ -f1,2", which is correct for SBo's own <category>/<package>/ layout but yields a file path in this repo's flat <package>/ layout (e.g. nuclei/nuclei.info). The guard then tested nuclei/nuclei.info/slack-desc, which never exists, so sbolint was silently skipped on every package commit. Walk up from each changed file to the directory holding the .SlackBuild instead. Depth is no longer assumed, so this works for the current flat layout and for <category>/<package>/ after the planned migration.
Diffstat (limited to '.extras')
-rwxr-xr-x.extras/hooks/pre-commit17
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"