Skip to content

Commit

Permalink
Introduce git push hook to validate source before push (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmxs authored Jun 8, 2022
1 parent 34b69e2 commit cfcf36b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .husky/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

husky install
18 changes: 18 additions & 0 deletions .husky/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

if [[ -n "$(git status --short)" ]]; then
git stash
function unstash() {
git reset --hard
git stash pop
}
trap unstash EXIT
fi

go fmt ./...
go vet ./...
golangci-lint run -c .golangci.yaml

git diff --exit-code --quiet || (git status && exit 1)
16 changes: 15 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,23 @@ tasks:
- bin-dir:init
desc: install kubectl
cmds:
- curl -Lo ./bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v{{.KUBECTL_VERSION}}/bin/{{OS}}/{{ARCH}}/kubectl && chmod +x ./bin/kubectl
- curl -Lo ./bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v{{.KUBECTL_VERSION}}/bin/{{OS}}/{{ARCH}}/kubectl
- chmod +x ./bin/kubectl
status:
- test -f ./bin/kubectl
fetch:husky:
deps:
- bin-dir:init
desc: install husky
cmds:
- cd bin ; curl -L https://github.com/automation-co/husky/releases/download/v0.2.8/husky_0.2.8_{{.CAP_ARCH}}_x86_64.tar.gz | tar -xz husky
- chmod +x ./bin/husky
- ./bin/husky install
vars:
CAP_ARCH:
sh: uname
status:
- test -f ./bin/husky
fetch:all:
desc: fetch all tools
cmds:
Expand Down

0 comments on commit cfcf36b

Please sign in to comment.