Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2017-01-05 13:50:47 +0300
committerJacob Vosmaer <jacob@gitlab.com>2017-01-05 13:55:40 +0300
commit1834cc190399a6d346c1d7c2db43207c2e2d414a (patch)
tree64ceb035fc9102d0bc3aafe64c3d5b460a5e6941
parent2c4e7ff35127475d1bf2e070beeda35a14ca14db (diff)
All code must pass "gofmt -s"
-rw-r--r--Makefile6
-rwxr-xr-x_support/gofmt-all27
2 files changed, 32 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index a8b75d25d..16d5ff49b 100644
--- a/Makefile
+++ b/Makefile
@@ -19,9 +19,13 @@ build: ${BUILD_DIR}/_build $(shell find . -name '*.go' -not -path './vendor/*')
cd ${PKG_BUILD_DIR} && $(foreach cmd,${CMDS},go build ./cmd/${cmd} && ) true
mv $(foreach cmd,${CMDS},${PKG_BUILD_DIR}/${cmd}) ${BUILD_DIR}/
-test: ${BUILD_DIR}/_build
+test: ${BUILD_DIR}/_build fmt
cd ${PKG_BUILD_DIR} && go test ./...
+.PHONY: fmt
+fmt:
+ _support/gofmt-all -n | awk '{ print } END { if (NR > 0) { print "Please run _support/gofmt-all -f"; exit 1 } }'
+
clean:
rm -rf ${BUILD_DIR}/_build
rm -rf client/testdata
diff --git a/_support/gofmt-all b/_support/gofmt-all
new file mode 100755
index 000000000..e8d80f892
--- /dev/null
+++ b/_support/gofmt-all
@@ -0,0 +1,27 @@
+#!/bin/sh
+set -e
+
+if [ $# -ne 1 ] ; then
+ echo "Usage: $0 [ -n | -f ]"
+ echo
+ echo "$0 runs 'gofmt -s' on all non-vendored .go files in this project."
+ echo " -n List files that would be changed"
+ echo " -f Apply changes"
+ exit 1
+fi
+
+gofmt='gofmt -s -l'
+case "x$1" in
+x-n)
+ # Command is already as it should be.
+ ;;
+x-f)
+ gofmt="${gofmt} -w"
+ ;;
+*)
+ echo "Invalid argument: $1"
+ exit 1
+ ;;
+esac
+
+${gofmt} $(find . -name '*.go' -not -path './vendor/*' -not -path './_*')