commit 8f4467c17509acf9a58f7b0b834951d604a64b36
parent 643223d169f1d9b53e9080ed78b13868a18d7973
Author: Shipwreckt <me@shipwreckt.co.uk>
Date: Sun, 23 Feb 2025 08:20:34 +0000
small changes
Diffstat:
2 files changed, 38 insertions(+), 20 deletions(-)
diff --git a/example_create.sh b/example_create.sh
@@ -1,4 +1,7 @@
#!/bin/sh
+
+# This script is ment to initialize your stagit website
+
# - Makes index for repositories in a single directory.
# - Makes static pages for each repository directory.
#
@@ -16,8 +19,16 @@
# - sh example_create.sh
# path must be absolute.
-reposdir="/var/www/domains/git.codemadness.nl/home/src"
-curdir="$(pwd)"
+
+# Repodir is where your git repos are located
+reposdir="/srv/git"
+
+#curdir is the current directory but I suggest switching it to your website directory
+# Current
+#curdir="$(pwd)"
+
+# Absolute
+curdir="/var/www/git/htmldir"
# make index.
stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
diff --git a/example_post-receive.sh b/example_post-receive.sh
@@ -1,7 +1,9 @@
#!/bin/sh
-# generic git post-receive hook.
-# change the config options below and call this script in your post-receive
-# hook or symlink it.
+# Git post-rreceive hook to update stagit when there is a git commit.
+# This will work on all of your git repos.
+#
+# Add this file to your git repo
+# /srv/git/<repo name>.git/hooks/post-receive
#
# usage: $0 [name]
#
@@ -14,36 +16,39 @@ export LC_CTYPE="en_US.UTF-8"
name="$1"
if test "${name}" = ""; then
- name=$(basename "$(pwd)")
+ name=$(basename "$(pwd)")
fi
# config
# paths must be absolute.
-reposdir="/home/src/src"
+
+# Reposdir is the directory your git repos are located
+reposdir="/srv/git"
dir="${reposdir}/${name}"
-htmldir="/home/www/domains/git.codemadness.org/htdocs"
+# htmldir is where your stagit static site is located
+htmldir="/var/www/git/htmldir"
stagitdir="/"
destdir="${htmldir}${stagitdir}"
cachefile=".htmlcache"
# /config
if ! test -d "${dir}"; then
- echo "${dir} does not exist" >&2
- exit 1
+ echo "${dir} does not exist" >&2
+ exit 1
fi
cd "${dir}" || exit 1
# detect git push -f
force=0
while read -r old new ref; do
- test "${old}" = "0000000000000000000000000000000000000000" && continue
- test "${new}" = "0000000000000000000000000000000000000000" && continue
+ test "${old}" = "0000000000000000000000000000000000000000" && continue
+ test "${new}" = "0000000000000000000000000000000000000000" && continue
- hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
- if test -n "${hasrevs}"; then
- force=1
- break
- fi
+ hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
+ if test -n "${hasrevs}"; then
+ force=1
+ break
+ fi
done
# strip .git suffix.
@@ -56,18 +61,20 @@ cd "${destdir}/${d}" || exit 1
# remove commits and ${cachefile} on git push -f, this recreated later on.
if test "${force}" = "1"; then
- rm -f "${cachefile}"
- rm -rf "commit"
+ rm -f "${cachefile}"
+ rm -rf "commit"
fi
# make index.
stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
# make pages.
-stagit -c "${cachefile}" -u "https://git.codemadness.nl/$d/" "${reposdir}/${r}"
+# Replace with your domain name please
+stagit -c "${cachefile}" -u "https://yourwebsite.com/$d/" "${reposdir}/${r}"
ln -sf log.html index.html
ln -sf ../style.css style.css
ln -sf ../logo.png logo.png
echo "done"
+