aboutsummaryrefslogtreecommitdiffstats
path: root/.extras/hooks/post-commit
diff options
context:
space:
mode:
authorDanilo Macrì <danix@danix.xyz>2026-04-03 12:20:05 -0400
committerGitHub <noreply@github.com>2026-04-03 12:20:05 -0400
commita7976bfe662097273e91471e2609df2d30120656 (patch)
treec54b2a6d28a89333b771bdee05e6baa45fe0c94f /.extras/hooks/post-commit
parent1045963959ddfb697898fa90476f837aae4e2881 (diff)
parentebb26eac2948e02def3c7ac1ac23c4ecd345a5a7 (diff)
downloadmy-slackbuilds-a7976bfe662097273e91471e2609df2d30120656.tar.gz
my-slackbuilds-a7976bfe662097273e91471e2609df2d30120656.zip
Merge pull request #5 from danixland/restructure-flat-layout
repo: flatten layout — move packages to root, extras to .extras/
Diffstat (limited to '.extras/hooks/post-commit')
-rwxr-xr-x.extras/hooks/post-commit51
1 files changed, 51 insertions, 0 deletions
diff --git a/.extras/hooks/post-commit b/.extras/hooks/post-commit
new file mode 100755
index 0000000..c9241ae
--- /dev/null
+++ b/.extras/hooks/post-commit
@@ -0,0 +1,51 @@
+#!/bin/bash
+# post-commit hook: create SBo submission archive for added/updated packages
+set -u
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+SBO_DIR="$REPO_ROOT/SBo"
+
+# Find packages whose .SlackBuild was added (A) or modified (M) in this commit.
+# git diff-tree output format: <status>\t<file>
+# We only want files exactly one directory deep, e.g. hugo/hugo.SlackBuild.
+PACKAGES=()
+while IFS=$'\t' read -r status file; do
+ [[ "$status" != "A" && "$status" != "M" ]] && continue
+ dir=$(dirname "$file")
+ base=$(basename "$file")
+ # Only process packages at SlackBuilds/<pkg> depth
+ [[ "$dir" =~ ^SlackBuilds/[^/]+$ ]] || continue
+ [[ "$base" == *.SlackBuild ]] || continue
+ PACKAGES+=("$dir")
+done < <(git diff-tree --no-commit-id -r --name-status HEAD)
+
+[[ ${#PACKAGES[@]} -eq 0 ]] && exit 0
+
+for pkg in "${PACKAGES[@]}"; do
+ echo ""
+ echo "==> Package: $pkg"
+ echo ""
+ echo "Files to be archived:"
+ echo "---------------------"
+ while IFS= read -r f; do
+ printf '%s\n' "${f#"$REPO_ROOT/"}"
+ done < <(find "$REPO_ROOT/$pkg" -type f | sort)
+ echo ""
+ printf "Create SBo archive for '%s'? [y/N] " "$pkg"
+ read -r answer </dev/tty
+ case "$answer" in
+ [yY]|[yY][eE][sS])
+ mkdir -p "$SBO_DIR"
+ if tar -czf "$SBO_DIR/$pkg.tar.gz" -C "$REPO_ROOT" "$pkg"; then
+ echo " -> Archive created: SBo/$pkg.tar.gz"
+ else
+ echo " -> Archive FAILED." >&2
+ fi
+ ;;
+ *)
+ echo " -> Skipped."
+ ;;
+ esac
+done
+
+exit 0