]> git.phdru.name Git - git-scripts.git/blobdiff - add-pubkey/post-checkout
Add scripts to put phd public key to an orphaned branch
[git-scripts.git] / add-pubkey / post-checkout
diff --git a/add-pubkey/post-checkout b/add-pubkey/post-checkout
new file mode 100755 (executable)
index 0000000..ae91c71
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# post-checkout hook that compiles python files to byte code
+# if branch was changed or remove byte code files for a specific branch
+
+prev_HEAD="$1"
+new_HEAD="$2"
+new_branch="$3"
+
+if [ \( "$new_branch" = 1 \) ]; then
+   phd_pubkey_HEAD="`git show-ref --hash refs/heads/phd-pubkey`"
+   if [ "$new_HEAD" = "$phd_pubkey_HEAD" ]; then
+      git clean -d -f -q
+   else
+      python2.7 -m compileall -q . &&
+      python2.7 -O -m compileall -q .
+   fi
+fi
+
+exit 0