]> git.armaanb.net Git - bin.git/commitdiff
git-mirror: add script
authorArmaan Bhojwani <me@armaanb.net>
Sat, 6 Mar 2021 00:59:00 +0000 (19:59 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sat, 6 Mar 2021 00:59:00 +0000 (19:59 -0500)
git-mirror [new file with mode: 0755]

diff --git a/git-mirror b/git-mirror
new file mode 100755 (executable)
index 0000000..146f9e0
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/sh -e
+
+case ${1} in
+  -h | --help)
+    echo "Usage: git-mirror [path to repos] [path to log file] [html directory]"
+    echo "relative paths are not supported."
+    exit 1
+    ;;
+esac
+
+[ -z ${3} ] && echo "not enough arguments" && exit 1
+[ -z $(which stagit) ] && echo "please install stagit" && exit 1
+
+cd ${1}
+
+[ -d ${3} ] || mkdir ${3}
+stagit-index ./* > ${3}/index.html
+cp /usr/share/doc/stagit/style.css ${3}
+
+while :; do
+  find ${1} -maxdepth 2 -name '*.git' | \
+    while read dir; do
+      newdir=${3}/$(basename ${dir} .git)
+      [ -d ${newdir} ] || mkdir ${newdir}
+      cd ${newdir}
+      stagit ${dir}
+      cp /usr/share/doc/stagit/style.css .
+      git fetch --tags
+      echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2}
+      echo $(tail -n 1500 ${2}) > ${2}
+    done
+  sleep 600
+done