mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Ensure goimports can be fixed individually.
Signed-off-by: James Blair <mail@jamesblair.net>
This commit is contained in:
parent
8c483f31ad
commit
2791422f77
6
Makefile
6
Makefile
@ -65,7 +65,7 @@ fuzz:
|
|||||||
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
|
verify: verify-gofmt verify-bom verify-lint verify-dep verify-shellcheck verify-goword \
|
||||||
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
|
verify-govet verify-license-header verify-receiver-name verify-mod-tidy verify-shellcheck \
|
||||||
verify-shellws verify-proto-annotations verify-genproto verify-goimport verify-yamllint
|
verify-shellws verify-proto-annotations verify-genproto verify-goimport verify-yamllint
|
||||||
fix: fix-bom fix-lint fix-yamllint
|
fix: fix-goimports fix-bom fix-lint fix-yamllint
|
||||||
./scripts/fix.sh
|
./scripts/fix.sh
|
||||||
|
|
||||||
.PHONY: verify-gofmt
|
.PHONY: verify-gofmt
|
||||||
@ -132,6 +132,10 @@ verify-genproto:
|
|||||||
verify-goimport:
|
verify-goimport:
|
||||||
PASSES="goimport" ./scripts/test.sh
|
PASSES="goimport" ./scripts/test.sh
|
||||||
|
|
||||||
|
.PHONY: fix-goimports
|
||||||
|
fix-goimports:
|
||||||
|
./scripts/fix-goimports.sh
|
||||||
|
|
||||||
.PHONY: verify-yamllint
|
.PHONY: verify-yamllint
|
||||||
verify-yamllint:
|
verify-yamllint:
|
||||||
yamllint --config-file tools/.yamllint .
|
yamllint --config-file tools/.yamllint .
|
||||||
|
28
scripts/fix-goimports.sh
Executable file
28
scripts/fix-goimports.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
source ./scripts/test_lib.sh
|
||||||
|
|
||||||
|
ROOTDIR=$(pwd)
|
||||||
|
|
||||||
|
# To fix according to newer version of go:
|
||||||
|
# go get golang.org/dl/gotip
|
||||||
|
# gotip download
|
||||||
|
# GO_CMD="gotip"
|
||||||
|
GO_CMD="go"
|
||||||
|
|
||||||
|
ROOTDIR=$(pwd)
|
||||||
|
|
||||||
|
function go_imports_fix {
|
||||||
|
GOFILES=$(run ${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
||||||
|
TESTGOFILES=$(run ${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
||||||
|
cd "${ROOTDIR}/tools/mod"
|
||||||
|
echo "${GOFILES}" "${TESTGOFILES}" | grep -v '.gw.go' | grep -v '.pb.go' | xargs -n 100 go run golang.org/x/tools/cmd/goimports -w -local go.etcd.io
|
||||||
|
}
|
||||||
|
|
||||||
|
log_callout -e "\\nFixing goimports for you...\n"
|
||||||
|
|
||||||
|
run_for_modules go_imports_fix || exit 2
|
||||||
|
|
||||||
|
log_success -e "\\nSUCCESS: goimports are fixed :)"
|
@ -8,8 +8,6 @@ go mod tidy
|
|||||||
source ./scripts/test_lib.sh
|
source ./scripts/test_lib.sh
|
||||||
source ./scripts/updatebom.sh
|
source ./scripts/updatebom.sh
|
||||||
|
|
||||||
ROOTDIR=$(pwd)
|
|
||||||
|
|
||||||
# To fix according to newer version of go:
|
# To fix according to newer version of go:
|
||||||
# go get golang.org/dl/gotip
|
# go get golang.org/dl/gotip
|
||||||
# gotip download
|
# gotip download
|
||||||
@ -31,20 +29,11 @@ function bash_ws_fix {
|
|||||||
find ./ -name '*.sh.bak' -print0 | xargs -0 rm
|
find ./ -name '*.sh.bak' -print0 | xargs -0 rm
|
||||||
}
|
}
|
||||||
|
|
||||||
function go_imports_fix {
|
|
||||||
GOFILES=$(run ${GO_CMD} list --f "{{with \$d:=.}}{{range .GoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
|
||||||
TESTGOFILES=$(run ${GO_CMD} list --f "{{with \$d:=.}}{{range .TestGoFiles}}{{\$d.Dir}}/{{.}}{{\"\n\"}}{{end}}{{end}}" ./...)
|
|
||||||
cd "${ROOTDIR}/tools/mod"
|
|
||||||
echo "${GOFILES}" "${TESTGOFILES}" | grep -v '.gw.go' | grep -v '.pb.go' | xargs -n 100 go run golang.org/x/tools/cmd/goimports -w -local go.etcd.io
|
|
||||||
}
|
|
||||||
|
|
||||||
log_callout -e "\\nFixing etcd code for you...\n"
|
log_callout -e "\\nFixing etcd code for you...\n"
|
||||||
|
|
||||||
run_for_modules mod_tidy_fix || exit 2
|
run_for_modules mod_tidy_fix || exit 2
|
||||||
run_for_modules run ${GO_CMD} fmt || exit 2
|
run_for_modules run ${GO_CMD} fmt || exit 2
|
||||||
run_for_module tests bom_fix || exit 2
|
run_for_module tests bom_fix || exit 2
|
||||||
log_callout "Fixing goimports..."
|
|
||||||
run_for_modules go_imports_fix || exit 2
|
|
||||||
bash_ws_fix || exit 2
|
bash_ws_fix || exit 2
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user