Skip to content

Instantly share code, notes, and snippets.

@alexjpaz
Created September 9, 2017 19:45
Show Gist options
  • Save alexjpaz/ba70c686fa361b1e9b00a2bd76c7b6f7 to your computer and use it in GitHub Desktop.
Save alexjpaz/ba70c686fa361b1e9b00a2bd76c7b6f7 to your computer and use it in GitHub Desktop.
git pre-receive hook to run a command with the newest ref on the master branch
#!/bin/bash
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo $oldrev $newrev $ref
echo $PWD
set -x
set -e
mkdir /tmp/$newrev
git archive $newrev | tar -x -C /tmp/$newrev
find /tmp/$newrev
cat /tmp/$newrev/foo
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment