ソースを参照

Fix #325 - Add git hook to auto-tidy pm/pl

George S. Baugh 4 ヶ月 前
コミット
1f211947a5
2 ファイル変更19 行追加1 行削除
  1. 5 1
      Installer.mk
  2. 14 0
      git-hooks/pre-commit

+ 5 - 1
Installer.mk

@@ -183,5 +183,9 @@ dns:
 	sudo service pdns enable
 	sudo service pdns start
 
+.PHONY: githook
+githook:
+	cp git-hooks/pre-commit .git/hooks
+
 .PHONY: all
-all: prereq-debian install fail2ban nginx mail
+all: prereq-debian install fail2ban nginx mail dns githook

+ 14 - 0
git-hooks/pre-commit

@@ -0,0 +1,14 @@
+#!/bin/sh
+
+to_tidy=$(git diff --cached --name-only  | egrep ".p[m|l]$")
+
+# Redirect output to stderr.
+exec 1>&2
+
+if [ $to_tidy  ]
+then
+    echo "Auto-tidying perl changes..."
+    perltidy -b $to_tidy
+    git add $to_tidy
+    echo "Done."
+fi