summaryrefslogtreecommitdiff
path: root/docs/hooks/leap-autopep8.post-commit.hook
diff options
context:
space:
mode:
Diffstat (limited to 'docs/hooks/leap-autopep8.post-commit.hook')
-rwxr-xr-xdocs/hooks/leap-autopep8.post-commit.hook15
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/hooks/leap-autopep8.post-commit.hook b/docs/hooks/leap-autopep8.post-commit.hook
new file mode 100755
index 00000000..cffb1d53
--- /dev/null
+++ b/docs/hooks/leap-autopep8.post-commit.hook
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Auto pep8 correction as a post-commit hook.
+# Thanks to http://victorlin.me/posts/2014/02/05/auto-post-commit-pep8-correction
+
+echo "[+] running autopep8..."
+FILES=$(git diff HEAD^ HEAD --name-only --diff-filter=ACM | grep -e '\.py$')
+
+for f in $FILES
+do
+ # auto pep8 correction
+ autopep8 --in-place $f
+done
+
+git status