git-server

git server-side stuff | stagit
git clone git://git.ckyln.com/~cem/hooks.git
Log | Files | Refs | README

commit edf7237a12bf94a07aed54a49ea4fd5b4f2eb4d5
parent 235c91ee400e0a0fb7acfb17c3ac6a2ecffb546b
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed, 10 Jun 2020 10:59:50 +0300

post-receive: create lsindex

Diffstat:
Alib | 29+++++++++++++++++++++++++++++
Mpost-receive | 5+++++
2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/lib b/lib @@ -0,0 +1,29 @@ +# Common functions for scripts + +out() { printf '%s\n' "$@" >&2 ;} +err() { printf 'err: %s\n' "$@" >&2 ;} +die() { err "$@"; exit 1 ;} + +lsindex() { + # This is a functionized version of lsindex. + # Script version: https://gist.github.com/4d8a03d65b7744365aaef88f7877cd22 + case "$1" in + '') set -- "$PWD" ;; + /*) ;; + *) set -- "$(cd "$1" || return 1; printf "$PWD")" + esac + + unset parentdir + curdir="${PWD#$1}" title="index of ${curdir:=/}" + + [ "$curdir" = / ] || { parentdir=${curdir%/*}; : "${parentdir:=/}" ;} + printf "<html><head><title>$title</title></head><body><h1>$title</h1><ul>" + + [ "$parentdir" ] && printf "<li><a href=$parentdir>Parent Directory</a></li>" + for file in *; do + [ "$file" = index.html ] && continue + [ -d "$file" ] && file="$file/" + printf '<li><a href="%s">&s</a></li>' "$file" "$file" + done + printf '%s\n' "</ul></body></html" + } diff --git a/post-receive b/post-receive @@ -11,6 +11,7 @@ # Parse the configuration file hooksdir=$(readlink -f "$0") hooksdir=${hooksdir%/*} . "$hooksdir/config" +. "$hooksdir/lib" # Store the repository name in a variable. We strip # the directory names and '.git' here. @@ -73,6 +74,10 @@ ln -sf log.html index.html -o "$tarball" \ -- "$tag" done + for dir in archive "archive/$repository"; do ( + cd "$STAGIT_DIR/$dir" + lsindex "$STAGIT_DIR" > index.html + ) done } [ "$RAW_ALL" = 1 ] || [ -f raw ] && {