commit 86c891b57ba1fe3b5753b37abd6e1bb17fc92a3d
parent 06d3c4b9ec335f8f7e80b6d3bf07a82769de8b00
Author: awy <awy@awy.one>
Date: Tue, 16 Dec 2025 04:59:51 +0300
helper scripts
refactor
Diffstat:
4 files changed, 107 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
@@ -30,6 +30,10 @@ COMPATSRC = \
BIN = \
stagit\
stagit-index
+SCRIPTS = \
+ stagit-gen-index\
+ stagit-newrepo\
+ stagit-rebuild-all
MAN1 = \
stagit.1\
stagit-index.1
@@ -80,6 +84,7 @@ install: all
# installing executable files.
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
+ cp -f ${SCRIPTS} ${DESTDIR}${PREFIX}/bin
for f in ${BIN}; do chmod 755 ${DESTDIR}${PREFIX}/bin/$$f; done
# installing example files.
mkdir -p ${DESTDIR}${DOCPREFIX}
@@ -98,6 +103,7 @@ install: all
uninstall:
# removing executable files.
for f in ${BIN}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
+ for f in ${SCRIPTS}; do rm -f ${DESTDIR}${PREFIX}/bin/$$f; done
# removing example files.
rm -f \
${DESTDIR}${DOCPREFIX}/style.css\
diff --git a/stagit-gen-index b/stagit-gen-index
@@ -0,0 +1,7 @@
+#!/bin/sh
+# Author: Cale "poptart" Black
+# License: MIT
+
+set -eu
+. /var/git/config.rc
+stagit-index "$GIT_HOME"/*.git > "$WWW_HOME/index.html"
diff --git a/stagit-newrepo b/stagit-newrepo
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Author: Cale "poptart" Black
+# License: MIT
+
+set -eu
+. /var/git/config.rc
+e_log() {
+ printf '%s\n' "$*"
+}
+
+e_err() {
+ printf '%s\n' "$*" >&2
+}
+
+e_exit() {
+ e_err "$*"
+ exit 1
+}
+
+DESC=""
+REPO=""
+
+if [ $# -gt 1 ]; then
+ DESC="$2"
+else
+ DESC="$DEFAULT_DESCRIPTION"
+fi
+
+if [ $# -eq 0 ]; then
+ e_exit "not enough args"
+else
+ REPO="$(basename "$1")"
+fi
+
+git init --bare "$GIT_HOME/$REPO.git"
+cp "$GIT_HOME/template/post-receive" "$GIT_HOME/$REPO.git/hooks/post-receive"
+
+echo "$CLONE_URI/$REPO" > "$GIT_HOME/$REPO.git/url"
+echo "$DEFAULT_OWNER" > "$GIT_HOME/$REPO.git/owner"
+
+if [ -n "$DESC" ]; then
+ echo "$DESC" > "$GIT_HOME/$REPO.git/description"
+else
+ echo "this is a placeholder" > "$GIT_HOME/$REPO.git/description"
+fi
+
+chmod u+x "$GIT_HOME/$REPO.git/hooks/post-receive"
+
+mkdir "$WWW_HOME/$REPO"
+
+/usr/local/bin/stagit-gen-index
diff --git a/stagit-rebuild-all b/stagit-rebuild-all
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+REPO_BASE="/var/git/repos"
+OUT_BASE="/var/www/htdocs/git"
+
+echo "==> Starting stagit rebuild"
+echo " Repos: $REPO_BASE"
+echo " Output: $OUT_BASE"
+echo
+
+for repo in "$REPO_BASE"/*.git; do
+ [ -e "$repo" ] || continue
+
+ name=$(basename "$repo" .git)
+ outdir="$OUT_BASE/$name"
+
+ echo "==> Processing repo: $name"
+ echo " Source: $repo"
+ echo " Target: $outdir"
+
+ if [ ! -d "$outdir" ]; then
+ echo " Creating directory: $outdir"
+ if ! mkdir -p "$outdir"; then
+ echo " ERROR: failed to create $outdir" >&2
+ exit 1
+ fi
+ fi
+
+ echo " Running stagit..."
+ if (
+ cd "$outdir" &&
+ stagit "$repo"
+ ); then
+ echo " Done: $name"
+ else
+ echo " ERROR: stagit failed for $name" >&2
+ exit 1
+ fi
+
+ echo
+done
+
+echo "==> All repositories processed"