Index

joshstock.in / 05d74a2

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
12313 Oct 2021 19:04370f1dbMerge branch 'deploy'Josh Stockin000G

Blob @ joshstock.in / pre-receive

text/x-shellscript1157 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 and exiting."
17 . $SCRIPTPATH/pre-receive $oldrev $newrev $ref
18 exit $?
19 else;
20 echo "No pre-receive hook modification."
21 fi
22 echo "Ref $ref received. Checking for post-receive hook modification..."
23 if [[ $(! git diff --name-only $oldrev $newrev | grep post-receive) ]]; then
24 echo "Updated post-receive hook detected. Installing..."
25 mkdir -p /tmp/newrev
26 git archive $newrev | tar -x -C /tmp/newrev
27 mv /tmp/newrev/post-receive $SCRIPTPATH/post-receive
28 rm -rf /tmp/newrev
29 else;
30 echo "No post-receive hook modification."
31 fi
32done
33