Skip to content

Include formatting check to the make test (and thus also check) rule #1366

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

Merged
merged 4 commits into from
Jun 6, 2017
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
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ BINDATA := modules/{options,public,templates}/bindata.go
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
JAVASCRIPTS :=
DOCKER_TAG := gitea/gitea:latest
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*" -not -path "*/bindata.go")
GOFMT ?= gofmt -s

GOFLAGS := -i -v
EXTRA_GOFLAGS ?=
Expand All @@ -12,7 +14,6 @@ LDFLAGS := -X "main.Version=$(shell git describe --tags --always | sed 's/-/+/'

PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations,$(shell go list ./... | grep -v /vendor/))
SOURCES ?= $(shell find . -name "*.go" -type f)
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")

TAGS ?=

Expand Down Expand Up @@ -42,9 +43,12 @@ clean:
go clean -i ./...
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA)

required-gofmt-version:
@go version | grep -q '\(1.7\|1.8\)' || { echo "We require go version 1.7 or 1.8 to format code" >&2 && exit 1; }

.PHONY: fmt
fmt:
find . -name "*.go" -type f -not -path "./vendor/*" | xargs gofmt -s -w
fmt: required-gofmt-version
$(GOFMT) -w $(GOFILES)

.PHONY: vet
vet:
Expand Down Expand Up @@ -88,8 +92,18 @@ misspell:
fi
misspell -w -i unknwon $(GOFILES)

.PHONY: fmt-check
fmt-check: required-gofmt-version
# get all go files and run go fmt on them
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;

.PHONY: test
test:
test: fmt-check
go test $(PACKAGES)

.PHONY: test-coverage
Expand Down
2 changes: 1 addition & 1 deletion models/repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"code.gitea.io/gitea/modules/markdown"
"code.gitea.io/gitea/modules/setting"

"github.com/stretchr/testify/assert"
"github.com/Unknwon/com"
"github.com/stretchr/testify/assert"
)

func TestRepo(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ var (

// Repository local settings
Local struct {
LocalCopyPath string
LocalCopyPath string
} `ini:"-"`
}{
AnsiCharset: "",
Expand Down Expand Up @@ -214,7 +214,7 @@ var (

// Repository local settings
Local: struct {
LocalCopyPath string
LocalCopyPath string
}{
LocalCopyPath: "tmp/local-repo",
},
Expand Down