-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bbcbf2
commit 1d64514
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
rm $(pwd)/../.git/hooks/pre-commit | ||
chmod +x git-hooks/pre-commit | ||
ln -s $(pwd)/pre-commit $(pwd)/../.git/hooks/pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
# Copyright 2012 The Go Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
|
||
STASH_NAME="pre-commit-$(date +%s)" | ||
git stash save -q --keep-index $STASH_NAME | ||
|
||
./run-tests.sh | ||
RESULT=$? | ||
|
||
git stash pop -q | ||
|
||
[ $RESULT -ne 0 ] && exit 1 | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script does not handle file names that contain spaces. | ||
|
||
# TESTS | ||
go test -v -race $(go list ./... | grep -v /vendor/) | ||
RESULT=$? | ||
[ $RESULT -ne 0 ] && exit 1 | ||
|
||
# FORMATTING | ||
gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.go$') | ||
[ -z "$gofiles" ] && exit 0 | ||
|
||
|
||
unformatted=$(gofmt -l $gofiles) | ||
[ -z "$unformatted" ] && exit 0 | ||
|
||
# Some files are not gofmt'd. Print message and fail. | ||
|
||
echo >&2 "Go files must be formatted with gofmt. Please run:" | ||
for fn in $unformatted; do | ||
echo >&2 " gofmt -w $PWD/$fn" | ||
done | ||
|
||
exit 1 |