From 51766cb4058a3e94e402cc33d9bd903633a245d1 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 7 Aug 2014 01:18:22 +0400 Subject: [PATCH] Add two post-checkout hooks as examples --- hooks/post-checkout-compile | 15 +++++++++++++++ hooks/post-checkout-touch | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 hooks/post-checkout-compile create mode 100755 hooks/post-checkout-touch diff --git a/hooks/post-checkout-compile b/hooks/post-checkout-compile new file mode 100755 index 0000000..10c729b --- /dev/null +++ b/hooks/post-checkout-compile @@ -0,0 +1,15 @@ +#!/bin/sh + +# post-checkout hook that compiles python files to byte code +# if branch was changed + +prev_HEAD="$1" +new_HEAD="$2" +new_branch="$3" + +if [ \( "$new_branch" = 1 \) ]; then + python2.7 -m compileall -q . && + python2.7 -O -m compileall -q . +fi + +exit 0 diff --git a/hooks/post-checkout-touch b/hooks/post-checkout-touch new file mode 100755 index 0000000..5bd00a2 --- /dev/null +++ b/hooks/post-checkout-touch @@ -0,0 +1,15 @@ +#!/bin/sh + +# post-checkout hook that change timestamps on files to that one of the commit +# if branch was changed + +prev_HEAD="$1" +new_HEAD="$2" +new_branch="$3" + +if [ "$new_branch" = 1 ]; then + commit_date="`git show --format='%cD' \"$new_HEAD\" | awk '{if (NR==1) print}'`" && + find . \( -name .git -type d -prune \) -o -exec touch --date="$commit_date" '{}' \+ +fi + +exit 0 -- 2.39.5