Skip to content

Commit

Permalink
Add staticrequired to pre-push hooks (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Aug 13, 2018
1 parent b8c1087 commit 8d570e7
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Hook scripts in this directory can be placed in .git/hooks to get git to help with our workflow. These are for developer use only, and have no impact by just being here in .githooks.

You should also be able to link them, for example (if you don't mind if they change upstream, and don't introduce any changes of your own)

The easiest way to do it is to use the script: `.githooks/linkallchecks.sh` and `.githooks/unlinkprepush.sh`. If you have a situation where you want to push without the checks, just `unlinkprepush.sh` and then put it back with `linkallchecks.sh`.

But what you're actually doing is this:
```
cd .git/hooks
# For all the static checks:
Expand Down
12 changes: 12 additions & 0 deletions .githooks/linkallchecks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

# Find the directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

ln -sf $DIR/pre-push.allchecks $DIR/../.git/hooks/pre-push

echo "Linked pre-push.allchecks as pre-push git hook"
12 changes: 12 additions & 0 deletions .githooks/linkgofmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

# Find the directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

ln -sf $DIR/pre-push.gofmt $DIR/../.git/hooks/pre-push

echo "Linked pre-push.gofmt as pre-push git hook"
3 changes: 2 additions & 1 deletion .githooks/pre-push.allchecks
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ git diff-index --quiet HEAD || (echo "There are uncommitted files" && exit 1)
# Look for unstaged files
test -z "$(git ls-files --exclude-standard --others)" || (echo "There are unstaged files" && exit 2)

make -s gofmt govet golint errcheck staticcheck codecoroner
# And check make staticrequired
make -s staticrequired
12 changes: 12 additions & 0 deletions .githooks/unlinkprepush.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -o errexit
set -o pipefail
set -o nounset

# Find the directory of this script
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

rm -f $DIR/../.git/hooks/pre-push

echo "Unlinked pre-push git hook"

0 comments on commit 8d570e7

Please sign in to comment.