Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check if go code is formatted #3421

Merged
merged 2 commits into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ PHONY += go_check deps vendor install build nofuse clean uninstall

test: test_expensive

test_short: build test_go_short test_sharness_short
test_short: test_go_fmt build test_go_short test_sharness_short

test_expensive: build test_go_expensive test_sharness_expensive windows_build_check
test_expensive: test_go_fmt build test_go_expensive test_sharness_expensive windows_build_check

test_3node:
$(MAKE) -C test/3nodetest

test_go_fmt:
bin/test-go-fmt

test_go_short:
$(go_test) -test.short ./...

Expand Down
15 changes: 15 additions & 0 deletions bin/test-go-fmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
T="$(mktemp)"
find . -name '*.go' | xargs gofmt -l > "$T"

if [ -n "$(cat $T)" ]; then
echo "Following Go code is not formatted."
echo "-----------------------------------"
cat "$T"
echo "-----------------------------------"
echo "Run 'go fmt ./...' in your source directory"
rm -f "$T"
exit 1
fi
rm -f "$T"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to exit 1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does.

1 change: 0 additions & 1 deletion unixfs/io/pbdagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,3 @@ func (dr *pbDagReader) Seek(offset int64, whence int) (int64, error) {
return 0, errors.New("invalid whence")
}
}