From: Jonathan Amery Date: Mon, 29 Sep 2014 13:42:37 +0000 (+0100) Subject: Some stuff. And a README X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~jdamery/git?p=random-stuff;a=commitdiff_plain;h=448d46fcad429ef9011a9ff255a84f3fd618831c Some stuff. And a README --- diff --git a/git/README.txt b/git/README.txt new file mode 100644 index 0000000..86691d1 --- /dev/null +++ b/git/README.txt @@ -0,0 +1,9 @@ +Three small bits: + +. new-git.sh - makes a bare repo on chiark, clones it, and pushes an + initial empty commit to it so that git push works as + expected. + +. post-update - a post-update hook that runs other post-update hooks + +. post-update-2chiark - a post-update hook that pushes to another repo diff --git a/git/new-git.sh b/git/new-git.sh new file mode 100755 index 0000000..74001fc --- /dev/null +++ b/git/new-git.sh @@ -0,0 +1,15 @@ +#! /bin/sh +set -e + +name="$1" +shift + +ssh chiark "mkdir scm/$name; cd scm/$name; git init --bare" + +git clone "chiark:scm/$name" + +cd "$name" + +git commit --allow-empty -m Initial + +git push origin master diff --git a/git/post-update b/git/post-update new file mode 100755 index 0000000..b8abcdd --- /dev/null +++ b/git/post-update @@ -0,0 +1,29 @@ +#!/bin/bash + +# Runs all executable pre-commit-* hooks and exits after, +# if any of them was not successful. +# +# Based on +# http://osdir.com/ml/git/2009-01/msg00308.html +# +# Modified by JDA to log to syslog + +data=$(cat) +exitcodes=() +hookname=`basename $0` + +# Run each hook, passing through STDIN and storing the exit code. +# We don't want to bail at the first failure, as the user might +# then bypass the hooks without knowing about additional issues. + +for hook in $GIT_DIR/hooks/$hookname-*; do + test -x "$hook" || continue + echo "$data" | "$hook" 2>&1 | logger -p local5.notice -t ArtibusWiki + exitcodes+=($?) +done + +# If any exit code isn't 0, bail. + +for i in "${exitcodes[@]}"; do + [ "$i" == 0 ] || exit $i +done diff --git a/git/post-update-2chiark b/git/post-update-2chiark new file mode 100755 index 0000000..4e2c773 --- /dev/null +++ b/git/post-update-2chiark @@ -0,0 +1,3 @@ +#! /bin/bash + +git push chiark-scm || true