瀏覽代碼

Add lefthook

DarthSim 5 年之前
父節點
當前提交
749924b2bd
共有 3 個文件被更改,包括 29 次插入0 次删除
  1. 10 0
      .lefthook/pre-commit/lint
  2. 10 0
      .lefthook/pre-push/test
  3. 9 0
      lefthook.yml

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

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if ! [ -x "$(which brew)" ]; then
+  export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix libffi)/lib/pkgconfig"
+fi
+
+export CGO_LDFLAGS_ALLOW="-s|-w"
+export CGO_CFLAGS_ALLOW="-Xpreprocessor"
+
+golangci-lint run

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

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+if ! [ -x "$(which brew)" ]; then
+  export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(brew --prefix libffi)/lib/pkgconfig"
+fi
+
+export CGO_LDFLAGS_ALLOW="-s|-w"
+export CGO_CFLAGS_ALLOW="-Xpreprocessor"
+
+go test

+ 9 - 0
lefthook.yml

@@ -0,0 +1,9 @@
+pre-commit:
+  scripts:
+    lint:
+      tags: lint
+
+pre-push:
+  scripts:
+    test:
+      tags: test