Browse Source

Run test/lint only when *.go/h/c files are changed

DarthSim 5 years ago
parent
commit
03512c2d0e
2 changed files with 10 additions and 0 deletions
  1. 5 0
      .lefthook/pre-commit/lint
  2. 5 0
      .lefthook/pre-push/test

+ 5 - 0
.lefthook/pre-commit/lint

@@ -1,5 +1,10 @@
 #!/bin/sh
 
+if ! git diff --name-only | grep -qe ".*\.go$"; then
+  echo "Nothing to lint"
+  exit 0;
+fi
+
 if [ -x "$(which brew)" ]; then
   export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix libffi)/lib/pkgconfig"
 fi

+ 5 - 0
.lefthook/pre-push/test

@@ -1,5 +1,10 @@
 #!/bin/sh
 
+if ! git diff --name-only | grep -qe ".*\.(go|h|c)$"; then
+  echo "Nothing to test"
+  exit 0;
+fi
+
 if [ -x "$(which brew)" ]; then
   export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix libffi)/lib/pkgconfig"
 fi