From c225725eec3edc03f3c65892c22069e3203e23f5 Mon Sep 17 00:00:00 2001 From: tkrop Date: Thu, 4 Jan 2024 18:41:33 +0100 Subject: [PATCH] fix: bash completion and sort ordering (#10) Signed-off-by: tkrop --- Makefile | 2 +- Makefile.base | 6 ++--- VERSION | 2 +- config/Makefile | 2 +- config/Makefile.base | 6 ++--- internal/make/fixtures/bash.out | 2 +- internal/make/fixtures/targets-trace.out | 28 ++++++++++++------------ internal/make/fixtures/targets.out | 26 +++++++++++----------- internal/make/make.go | 2 +- 9 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index 9c0b6c5..822be13 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ else endif GOBIN ?= $(shell go env GOPATH)/bin -GOMAKE ?= github.com/tkrop/go-make@v0.0.16 +GOMAKE ?= github.com/tkrop/go-make@v0.0.17 TARGETS := $(shell command -v go-make >/dev/null || \ go install $(GOMAKE) && go-make targets) diff --git a/Makefile.base b/Makefile.base index 91d162c..63b90ee 100644 --- a/Makefile.base +++ b/Makefile.base @@ -167,8 +167,8 @@ TARGETS_LINT ?= lint-leaks? lint-$(CODE_QUALITY) lint-markdown lint-apis \ $(if $(filter $(CODACY),enabled),lint-codacy,) INIT_MAKE ?= $(notdir $(FILE_MAKE) $(FILE_VARS)) -UPDATE_MAKE ?= $(FILE_MAKE) $(FILE_GOLANGCI) $(FILE_MARKDOWN) \ - $(FILE_GITLEAKS) $(FILE_CODACY) $(FILE_REVIVE) +UPDATE_MAKE ?= $(notdir $(FILE_MAKE) $(FILE_GOLANGCI) $(FILE_MARKDOWN) \ + $(FILE_GITLEAKS) $(FILE_CODACY) $(FILE_REVIVE)) # Setup go to use desired and consistent go versions. GOVERSION := $(shell go version | sed -E "s/.*go([0-9]+\.[0-9]+).*/\1/") @@ -363,7 +363,7 @@ targets:: if [ "$(RUNARGS)" != "raw" ]; then awk -v RS= -F: ' \ /(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ { \ if ($$1 !~ "^[#.]") { print $$1 } \ - }' | sort -d | egrep -v -e '^[^[:alnum:]]'; \ + }' | LC_ALL=C sort | egrep -v -e '^[^[:alnum:]]'; \ else cat -; fi || true; #@ create a clone of the base repository to update from. diff --git a/VERSION b/VERSION index e3b86dd..cd23180 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.16 +0.0.17 diff --git a/config/Makefile b/config/Makefile index 9c0b6c5..822be13 100644 --- a/config/Makefile +++ b/config/Makefile @@ -8,7 +8,7 @@ else endif GOBIN ?= $(shell go env GOPATH)/bin -GOMAKE ?= github.com/tkrop/go-make@v0.0.16 +GOMAKE ?= github.com/tkrop/go-make@v0.0.17 TARGETS := $(shell command -v go-make >/dev/null || \ go install $(GOMAKE) && go-make targets) diff --git a/config/Makefile.base b/config/Makefile.base index 91d162c..63b90ee 100644 --- a/config/Makefile.base +++ b/config/Makefile.base @@ -167,8 +167,8 @@ TARGETS_LINT ?= lint-leaks? lint-$(CODE_QUALITY) lint-markdown lint-apis \ $(if $(filter $(CODACY),enabled),lint-codacy,) INIT_MAKE ?= $(notdir $(FILE_MAKE) $(FILE_VARS)) -UPDATE_MAKE ?= $(FILE_MAKE) $(FILE_GOLANGCI) $(FILE_MARKDOWN) \ - $(FILE_GITLEAKS) $(FILE_CODACY) $(FILE_REVIVE) +UPDATE_MAKE ?= $(notdir $(FILE_MAKE) $(FILE_GOLANGCI) $(FILE_MARKDOWN) \ + $(FILE_GITLEAKS) $(FILE_CODACY) $(FILE_REVIVE)) # Setup go to use desired and consistent go versions. GOVERSION := $(shell go version | sed -E "s/.*go([0-9]+\.[0-9]+).*/\1/") @@ -363,7 +363,7 @@ targets:: if [ "$(RUNARGS)" != "raw" ]; then awk -v RS= -F: ' \ /(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ { \ if ($$1 !~ "^[#.]") { print $$1 } \ - }' | sort -d | egrep -v -e '^[^[:alnum:]]'; \ + }' | LC_ALL=C sort | egrep -v -e '^[^[:alnum:]]'; \ else cat -; fi || true; #@ create a clone of the base repository to update from. diff --git a/internal/make/fixtures/bash.out b/internal/make/fixtures/bash.out index 13f5436..840cc4a 100644 --- a/internal/make/fixtures/bash.out +++ b/internal/make/fixtures/bash.out @@ -1,6 +1,6 @@ ### bash completion for go-make function __complete_go-make() { - COMPREPLY=($(compgen -W "$(go-make targets)" -- "${COMP_WORDS[COMP_CWORD]}")); + COMPREPLY=($(compgen -W "$(go-make targets 2>/dev/null)" -- "${COMP_WORDS[COMP_CWORD]}")); } complete -F __complete_go-make go-make; diff --git a/internal/make/fixtures/targets-trace.out b/internal/make/fixtures/targets-trace.out index 5c9f3a0..bcf4092 100644 --- a/internal/make/fixtures/targets-trace.out +++ b/internal/make/fixtures/targets-trace.out @@ -4,7 +4,7 @@ make --no-builtin-rules --no-builtin-variables --print-data-base \ if [ "" != "raw" ]; then awk -v RS= -F: ' \ /(^|\n)# Files(\n|$)/,/(^|\n)# Finished Make data base/ { \ if ($1 !~ "^[#.]") { print $1 } \ - }' | sort -d | egrep -v -e '^[^[:alnum:]]'; \ + }' | LC_ALL=C sort | egrep -v -e '^[^[:alnum:]]'; \ else cat -; fi || true; all all-clean @@ -38,19 +38,19 @@ init-gosec init-hooks init-make init-make! -init/Makefile -init/Makefile.vars init-sources init-staticcheck +init/Makefile +init/Makefile.vars install install-all install-deadcode install-gitleaks +install-go-make install-gocognit install-gocyclo install-golangci-lint install-gomajor -install-go-make install-gosec install-govulncheck install-grype @@ -112,11 +112,11 @@ uninstall-codacy-gosec uninstall-codacy-staticcheck uninstall-deadcode uninstall-gitleaks +uninstall-go-make uninstall-gocognit uninstall-gocyclo uninstall-golangci-lint uninstall-gomajor -uninstall-go-make uninstall-gosec uninstall-govulncheck uninstall-markdownlint @@ -127,7 +127,6 @@ uninstall-staticcheck uninstall-vegeta uninstall-zally update -update? update-all update-all? update-deadcode @@ -135,14 +134,12 @@ update-deps update-deps? update-gitleaks update-go +update-go-make update-go? update-gocognit update-gocyclo update-golangci-lint update-gomajor -update-go-make -update/go.mod -update/go.mod? update-gosec update-govulncheck update-make @@ -151,18 +148,21 @@ update-mock update-mockgen update-revive update-staticcheck +update-tools +update-vegeta +update-zally update/.codacy.yaml update/.codacy.yaml? update/.gitleaks.toml update/.gitleaks.toml? update/.golangci.yaml update/.golangci.yaml? -update/Makefile -update/Makefile? update/.markdownlint.yaml update/.markdownlint.yaml? +update/Makefile +update/Makefile? +update/go.mod +update/go.mod? update/revive.toml update/revive.toml? -update-tools -update-vegeta -update-zally +update? diff --git a/internal/make/fixtures/targets.out b/internal/make/fixtures/targets.out index fe7b1f0..44812a4 100644 --- a/internal/make/fixtures/targets.out +++ b/internal/make/fixtures/targets.out @@ -30,19 +30,19 @@ init-gosec init-hooks init-make init-make! -init/Makefile -init/Makefile.vars init-sources init-staticcheck +init/Makefile +init/Makefile.vars install install-all install-deadcode install-gitleaks +install-go-make install-gocognit install-gocyclo install-golangci-lint install-gomajor -install-go-make install-gosec install-govulncheck install-grype @@ -104,11 +104,11 @@ uninstall-codacy-gosec uninstall-codacy-staticcheck uninstall-deadcode uninstall-gitleaks +uninstall-go-make uninstall-gocognit uninstall-gocyclo uninstall-golangci-lint uninstall-gomajor -uninstall-go-make uninstall-gosec uninstall-govulncheck uninstall-markdownlint @@ -119,7 +119,6 @@ uninstall-staticcheck uninstall-vegeta uninstall-zally update -update? update-all update-all? update-deadcode @@ -127,14 +126,12 @@ update-deps update-deps? update-gitleaks update-go +update-go-make update-go? update-gocognit update-gocyclo update-golangci-lint update-gomajor -update-go-make -update/go.mod -update/go.mod? update-gosec update-govulncheck update-make @@ -143,18 +140,21 @@ update-mock update-mockgen update-revive update-staticcheck +update-tools +update-vegeta +update-zally update/.codacy.yaml update/.codacy.yaml? update/.gitleaks.toml update/.gitleaks.toml? update/.golangci.yaml update/.golangci.yaml? -update/Makefile -update/Makefile? update/.markdownlint.yaml update/.markdownlint.yaml? +update/Makefile +update/Makefile? +update/go.mod +update/go.mod? update/revive.toml update/revive.toml? -update-tools -update-vegeta -update-zally +update? diff --git a/internal/make/make.go b/internal/make/make.go index 6ad14c1..c7d0072 100644 --- a/internal/make/make.go +++ b/internal/make/make.go @@ -23,7 +23,7 @@ const ( // bashCompletion contains the bash completion script for go-make. BashCompletion = "### bash completion for go-make\n" + "function __complete_go-make() {\n" + - " COMPREPLY=($(compgen -W \"$(go-make targets)\"" + + " COMPREPLY=($(compgen -W \"$(go-make targets 2>/dev/null)\"" + " -- \"${COMP_WORDS[COMP_CWORD]}\"));\n" + "}\n" + "complete -F __complete_go-make go-make;\n"