commit faacb3c32b00c617621d0030d2bdaef1b10a0684
parent f770dc4319c15550653f072b0d61c88ccbdd892b
Author: Chris Bracken <chris@bracken.jp>
Date: Fri, 10 May 2024 00:55:05 -0700
Migrate grm from stagit to gitout
Diffstat:
3 files changed, 23 insertions(+), 100 deletions(-)
diff --git a/grm b/grm
@@ -23,23 +23,23 @@ GRM_OWNER="Chris Bracken"
# default url prefix (without ending slash)
GRM_URL_PREFIX="https://git.bracken.jp"
-# path of the post-receive hooks for stagit
+# path of the post-receive hooks for gitout
GRM_POSTRECV_HOOK="/home/git/git_infra/post-receive"
GRM_POSTRECV_HOOKS_DIR="/home/git/git_infra/post-receive.d"
-# root directory of stagit web pages
-STAGIT_WEB_ROOT="/usr/local/www/git.bracken.jp"
+# root directory of gitout web pages
+GITOUT_WEB_ROOT="/usr/local/www/git.bracken.jp"
# #
# #
#--------------------------------------------#
-# for stagit
+# for gitout
export LC_CTYPE="en_US.UTF-8"
prog_name="${0##*/}"
repos_root=${GRM_REPOS_ROOT:-/home/git}
-web_root=${STAGIT_WEB_ROOT:-/srv/git}
+web_root=${GITOUT_WEB_ROOT:-/srv/git}
recompile_repo() {
repo_dir="${repos_root}/${1}.git"
@@ -49,19 +49,19 @@ recompile_repo() {
[ -d "$repo_dir" ] || { echo "[$1] repo not found"; return 1; }
if [ -e "$repo_dir/git-daemon-export-ok" ]; then
- echo "[$1] recompiling stagit pages..."
+ echo "[$1] recompiling gitout pages..."
mkdir -p "$repo_web_dir"
cd "${repo_web_dir:?}" && \
rm -f "$cachefile" && \
rm -rf "commit" "file" && \
- stagit -c "$cachefile" "$repo_dir" && \
+ gitout -c "$cachefile" "$repo_dir" && \
ln -sf log.html index.html && \
ln -sf ../logo.png logo.png && \
ln -sf ../style.css style.css && \
ln -sf ../favicon.png favicon.png && \
echo "[$1] done!"
else
- echo "[$1] Not recompiling stagit pages: private repo"
+ echo "[$1] Not recompiling gitout pages: private repo"
fi
}
@@ -70,19 +70,19 @@ rebuild_index() {
mkdir -p "${web_root}" || return 1;
# 1. find all directories in $repos_root ending with .git
# 2. filter all the public repos (with git-daemon-export-ok)
- # 3. exclude any repo marked with stagit-no-index
+ # 3. exclude any repo marked with gitout-no-index
# 4. sort the result
# 5. hack for posix compatibility
- # 6. run stagit-index on the result
+ # 6. run gitout_index on the result
# 7. export result to index.html
find "${repos_root}/." ! -name . -prune \
-type d -name "*.git" \
-exec test -e "{}/git-daemon-export-ok" \;\
- -exec test ! -e "{}/stagit-no-index" \; \
+ -exec test ! -e "{}/gitout-no-index" \; \
-print \
| sort -f \
| sed -e 's/"/"\\""/g' -e 's/.*/"&"/' \
- | xargs stagit-index \
+ | xargs gitout_index \
> "${web_root}/index.html" && \
echo "[index] done!"
}
@@ -138,16 +138,16 @@ ${BLUE}enter index [default: ${GREEN}1${BLUE}]${RESET}"
# start creating repo
git init --bare "$repo_path"
- echo "writing stagit metadata..."
+ echo "writing gitout metadata..."
printf "%s\n" "$repo_desc" > "$repo_path/description"
printf "%s\n" "$owner" > "$repo_path/owner"
printf "%s\n" "$clone_url" > "$repo_path/url"
echo "setting visibility..."
[ "$exported" = "1" ] && : >> "$repo_path/git-daemon-export-ok"
- [ "$hidden" = "1" ] && : >> "$repo_path/stagit-no-index"
+ [ "$hidden" = "1" ] && : >> "$repo_path/gitout-no-index"
- echo "installing stagit post-receive hook..."
+ echo "installing gitout post-receive hook..."
ln -sf "$GRM_POSTRECV_HOOK" "$repo_path/hooks/post-receive"
mkdir -p "$repo_path/hooks/post-receive.d"
for hook in "$(ls "$GRM_POSTRECV_HOOKS_DIR")"; do
@@ -169,8 +169,8 @@ grm_remove() {
rm -rf "${web_root:?}/${repo:?}" || continue;
fi
done
- # only rebuild index if stagit exists
- command -v stagit-index >/dev/null && rebuild_index &
+ # only rebuild index if gitout exists
+ command -v gitout_index >/dev/null && rebuild_index &
wait
}
@@ -180,7 +180,7 @@ grm_list() {
find "${repos_root}/." ! -name . -prune \
-type d -name "*.git" \
-exec test -e "{}/git-daemon-export-ok" \; \
- -exec test ! -e "{}/stagit-no-index" \; \
+ -exec test ! -e "{}/gitout-no-index" \; \
-exec basename {} '.git' \; | sort -f ;;
private)
find "${repos_root}/." ! -name . -prune \
@@ -191,7 +191,7 @@ grm_list() {
find "${repos_root}/." ! -name . -prune \
-type d -name "*.git" \
-exec test -e "{}/git-daemon-export-ok" \; \
- -exec test -e "{}/stagit-no-index" \; \
+ -exec test -e "{}/gitout-no-index" \; \
-exec basename {} '.git' \; | sort -f ;;
*)
find "${repos_root}/." ! -name . -prune \
@@ -227,7 +227,7 @@ grm_info() {
printf "visibility: "
if [ -e "${repo_dir}/git-daemon-export-ok" ]; then
- if [ -e "${repo_dir}/stagit-no-index" ]; then
+ if [ -e "${repo_dir}/gitout-no-index" ]; then
printf "%b\n" "${YELLOW}unlisted${RESET}"
else
printf "%b\n" "${GREEN}public${RESET}"
@@ -266,8 +266,8 @@ commands:
ls private list private repos
ls unlisted list unlisted (hidden) repos
rm repo1 [repo2..] remove repos
- rc recompile stagit index
- rc repo1 [repo2..] recompile stagit pages for repos,
+ rc recompile gitout index
+ rc repo1 [repo2..] recompile gitout pages for repos,
and recompile index
rca recompile all public repos
help show help
diff --git a/post-receive.d/stagit b/post-receive.d/stagit
@@ -1,77 +0,0 @@
-#!/bin/sh -e
-
-export LC_CTYPE="en_US.UTF-8"
-
-# HTML root directory into which stagit will write.
-www_root="/usr/local/www/git.bracken.jp"
-
-# Hooks are called from the repo directory.
-repo_dir=$(pwd)
-
-# The stagit cache file.
-# This is an optimisation to avoid regenerating all pages on each push.
-cachefile="${repo_dir}/.htmlcache"
-
-# The directory under which all repos are located.
-# Repos under this directory will be added to the repo index page.
-repos_root=$(dirname "$repo_dir")
-
-# The user-friendly name of the repository.
-repo_name=$(basename "$repo_dir" '.git')
-
-# Detect --force pushes.
-cd "${repo_dir}" || exit 1
-force=0
-while read -r old new _; do
- [ "${old}" = "0000000000000000000000000000000000000000" ] && continue
- [ "${new}" = "0000000000000000000000000000000000000000" ] && continue
-
- hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
- if [ -n "$hasrevs" ]; then
- echo "[stagit] Force push detected: cleaning cache"
- force=1
- break
- fi
-done
-
-# If there was a --force push, delete all existing pages. The lack of a cache
-# file will trigger a full rebuild below.
-if [ "$force" = "1" ]; then
- rm -f "$cachefile"
- rm -rf "commit" "file"
-fi
-
-# Build the pages. If $cachefile is not present, a full rebuild is performed.
-if [ -e "${repo_dir}/git-daemon-export-ok" ]; then
- # Change to the directory where we will output HTML pages.
- repo_web_dir="${www_root}/${repo_name}"
- mkdir -p "$repo_web_dir"
- cd "$repo_web_dir" || exit 1
-
- # Generate the index page.
- # Any repo containing a stagit-no-index file will not be indexed.
- echo "[stagit] Building repo index"
- find "${repos_root}/." -maxdepth 1 \
- -type d \
- -name "*.git" \
- -exec test -e "{}/git-daemon-export-ok" \; \
- -exec test ! -e "{}/stagit-no-index" \; \
- -print \
- | sort -f \
- | sed -e 's/"/"\\""/g' -e 's/.*/"&"/' \
- | xargs stagit-index \
- > "${www_root}/index.html"
-
- # Rebuild the pages for the repo (including for unlisted repos).
- echo "[stagit] Building pages"
- stagit -c "$cachefile" "$repo_dir"
-
- # use log as index page
- echo "[stagit] Linking assets"
- ln -sf log.html index.html
- ln -sf ../style.css style.css
- ln -sf ../logo.png logo.png
- ln -sf ../favicon.png favicon.png
-else
- echo "[stagit] Not building pages: private repo"
-fi
diff --git a/update_mirrors.sh b/update_mirrors.sh
@@ -42,7 +42,7 @@ fetch_mirrors() {
printerr "[git mirror] ... $mirror"
git fetch
- # Regenerate stagit pages for public, unlisted repos.
+ # Regenerate static pages for public, unlisted repos.
if [ -e git-daemon-export-ok ]; then
grm rc `basename "$mirror" '.git'`
fi