[gtk-doc] tools: add a pre-commit check for the python code
- From: Stefan Sauer <stefkost src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc] tools: add a pre-commit check for the python code
- Date: Wed, 5 Apr 2017 18:35:46 +0000 (UTC)
commit 384a053cbf6bb407c75d2b7cf40638bb94d32bd8
Author: Stefan Sauer <ensonic users sf net>
Date: Wed Apr 5 20:20:49 2017 +0200
tools: add a pre-commit check for the python code
tools/git-pre-commit | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/tools/git-pre-commit b/tools/git-pre-commit
new file mode 100755
index 0000000..2b1e189
--- /dev/null
+++ b/tools/git-pre-commit
@@ -0,0 +1,18 @@
+#!/bin/sh
+# git hook to ensure code style
+# cp tools/git-pre-commit .git/hooks/pre-commit
+
+which >/dev/null pep8 || (echo "please install pep8"; exit )
+files=$(git diff --name-only --staged --diff-filter=ACMRTUXB | egrep "*.py$")
+
+if test -n "$files"; then
+ pep8 --max-line-length=120 $files
+ res=$?
+ if [ $res -ne 0 ]; then
+ echo
+ autopep8 --max-line-length=120 --diff $files
+ echo
+ echo "To fix run: autopep8 --max-line-length=120 -i $files"
+ fi
+ exit $res
+fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]