Index

joshstock.in / f409688

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
12913 Oct 2021 20:25f409688Update pre-receiveJosh Stockin132G

Blob @ joshstock.in / pre-receive

text/x-shellscript1200 bytesdownload raw
1#!/bin/bash
2
3# .git/hooks/pre-receive
4
5SCRIPTPATH=$(dirname $(realpath -s $0))
6
7while read oldrev newrev ref
8do
9 echo "Ref $ref received. Checking for pre-receive hook modification..."
10 if [[ $(! git diff --name-only $oldrev $newrev | grep pre-receive) ]]; then
11 echo "Updated pre-receive hook detected. Installing..."
12 mkdir -p /tmp/newrev
13 git archive $newrev | tar -x -C /tmp/newrev
14 mv /tmp/newrev/pre-receive $SCRIPTPATH/pre-receive
15 rm -rf /tmp/newrev
16 echo "Running new pre-receive hook."
17 echo "$oldrev $newrev $ref" | $SCRIPTPATH/pre-receive
18 echo "Done running new pre-receive hook."
19 exit $?
20 else
21 echo "No pre-receive hook modification."
22 fi
23 echo "Ref $ref received. Checking for post-receive hook modification..."
24 if [[ $(! git diff --name-only $oldrev $newrev | grep post-receive) ]]; then
25 echo "Updated post-receive hook detected. Installing..."
26 mkdir -p /tmp/newrev
27 git archive $newrev | tar -x -C /tmp/newrev
28 mv /tmp/newrev/post-receive $SCRIPTPATH/post-receive
29 rm -rf /tmp/newrev
30 else
31 echo "No post-receive hook modification."
32 fi
33done
34