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 (GitLab) <jacob@gitlab.com>2017-01-05 13:58:26 +0300
committerJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-01-05 13:58:26 +0300
commit7f85b73b414127fe7ca2afc1f729631b8c51c23f (patch)
treef7c6021feb03fc04c129cd8f541d7cc091e51bf8
parente3f1dceaf68c4322928a8ac3216c9a6dc98eca4b (diff)
parentd625fbb04676f4a8d7d7d5e7219fd73f3fe3044a (diff)
Merge branch 'gofmt' into 'master'
All code must pass "gofmt -s" See merge request !34
-rw-r--r--Makefile6
-rwxr-xr-x_support/gofmt-all27
-rw-r--r--helper/logging_test.go20
3 files changed, 42 insertions, 11 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 './_*')
diff --git a/helper/logging_test.go b/helper/logging_test.go
index c51bf9ea7..f116784ca 100644
--- a/helper/logging_test.go
+++ b/helper/logging_test.go
@@ -5,15 +5,15 @@ import (
)
func TestParsingCommandSuccessfully(t *testing.T) {
- cases := make(map[string][]string)
- cases["foo"] = []string{"--long-arg", "path/arg", "-f", "foo", "arg1", "arg2"}
- cases["bar"] = []string{"bar", "-d", "arg1", "arg2"}
- cases["baz"] = []string{"baz", "-f=\"some_value\""}
+ cases := make(map[string][]string)
+ cases["foo"] = []string{"--long-arg", "path/arg", "-f", "foo", "arg1", "arg2"}
+ cases["bar"] = []string{"bar", "-d", "arg1", "arg2"}
+ cases["baz"] = []string{"baz", "-f=\"some_value\""}
- for k,v := range cases {
- subCmd := ExtractSubcommand(v)
- if k != subCmd {
- t.Error("Expected subcommand for", v, "to be", k, ", got", subCmd)
- }
- }
+ for k, v := range cases {
+ subCmd := ExtractSubcommand(v)
+ if k != subCmd {
+ t.Error("Expected subcommand for", v, "to be", k, ", got", subCmd)
+ }
+ }
}