stagit-scripts

Personal companion scripts for stagit
git clone _git@git.zakaria.org/stagit-scripts.git
Log | Files | Refs | README

commit 6a1744f6618654165d642bef72a04c05564d2f75
Author: zakaria <e-zk@users.noreply.github.com>
Date:   Mon, 31 Jan 2022 18:08:19 +1000

Initial commit

Diffstat:
AREADME | 32++++++++++++++++++++++++++++++++
Ahooks/post-receive | 29+++++++++++++++++++++++++++++
Astagit-chdesc | 31+++++++++++++++++++++++++++++++
Astagit-gen-index | 10++++++++++
Astagit-newrepo | 39+++++++++++++++++++++++++++++++++++++++
5 files changed, 141 insertions(+), 0 deletions(-)

diff --git a/README b/README @@ -0,0 +1,32 @@ +stagit-scripts +=============== +companion scripts for stagit. based on the ones written by poptart[^1]. +common variables can be configured in /var/git/config.rc. + +stagit-newrepo +--------------- +create a new repository. +usage: stagit-newrepo <name> [description] [author] + +stagit-gen-index +----------------- +generate the index.html using variables from config.rc. + +stagit-chdesc +-------------- +change the description of an existing repository. +usage: stagit-chdesc <repo> [new_description] + +stagit-rm +---------- +remove a repository. +usage: stagit-rm <repo> + +license +-------- +licensed under MIT. +scripts stagit-newrepo, stagit-gen-index, and hooks/post-receive originally +written by Cale "poptart" Black. + +---- +[^1]: https://hosakacorp.net/p/stagit-server.html diff --git a/hooks/post-receive b/hooks/post-receive @@ -0,0 +1,29 @@ +#!/bin/sh +# Author: Cale "poptart" Black +# Modified by: zakaria @ zakaria.org +# License: MIT + +set -euf + +. /var/git/config.rc + +export LC_TYPE="en_US.UTF-8" +src="$(pwd)" +name="$(basename "$src")" +dest="${WWW_HOME}/$(basename "$name" '.git')" +mkdir -p "$dest" +cd "$dest" || exit 1 + +echo "[stagit] building $dest" +/usr/local/bin/stagit "$src" + +echo "[stagit] linking $dest" +# if a README.html exists use that as the index.html +# if not use log.html +if [ -f "README.html" ]; then + ln -sf README.html index.html +else + ln -sf log.html index.html +fi +ln -sf ../style.css style.css +ln -sf ../logo.png logo.png diff --git a/stagit-chdesc b/stagit-chdesc @@ -0,0 +1,31 @@ +#!/bin/sh +# Author: zakaria / zakaria.org +# License: MIT +# Usage: stagit-chdesc <repo> <new_description> + +set -eu + +. /var/git/config.rc + +log() { + printf '%s\n' "$*" >&2 +} +die() { + log "error: $*" + printf 'exiting...\n' + exit 1 +} + +REPO="$1" +DESC="$2" + +if [ -z "$REPO" ]; then + die "no repo name provided" +fi +if [ -z "$DESC" ]; then + die "no new description provided" +fi + +REPO_PATH="${GIT_REPOS}/${REPO}.git" + +echo "$DESC" > ${REPO_PATH}/description diff --git a/stagit-gen-index b/stagit-gen-index @@ -0,0 +1,10 @@ +#!/bin/sh +# Author: Cale "poptart" Black +# Modified by: zakaria @ zakaria.org +# License: MIT + +set -eu + +. /var/git/config.rc + +stagit-index "${GIT_REPOS}"/*.git > "${WWW_HOME}/index.html" diff --git a/stagit-newrepo b/stagit-newrepo @@ -0,0 +1,39 @@ +#!/bin/sh +# Author: Cale "poptart" Black +# Modified by: zakaria @ zakaria.org +# License: MIT +# Usage: stagit-newrepo <name> [desc] [author] + +set -eu + +. /var/git/config.rc + +log() { + printf '%s\n' "$*" >&2 +} +die() { + log "error: $*" + printf 'exiting...\n' + exit 1 +} + +REPO="$1" +DESC="${2:-$DEFAULT_DESC}" +OWNER="${3:-$DEFAULT_OWNER}" + +if [ -z "$REPO" ]; then + die "no repo name given" +fi + +REPO_PATH="${GIT_REPOS}/${REPO}.git" + +git init --bare "$REPO_PATH" +cp "${GIT_HOME}/template/post-receive" "${REPO_PATH}/hooks/post-receive" +echo "${CLONE_URI}/${REPO}.git" > "${REPO_PATH}/url" +echo "$OWNER" > "${REPO_PATH}/owner" +echo "$DESC" > "${REPO_PATH}/description" + +chmod u+x "${REPO_PATH}/hooks/post-receive" +mkdir "${WWW_HOME}/${REPO}" + +/usr/local/bin/stagit-gen-index