--version goes to stderr and the Docker image always reports "dev" #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
main.go:37declaresVersionandmain.go:44wires it into cobra, so-X main.Version=...does work from a localmake build. Two things are still wrong.The version string goes to stderr.
main.go:54-55routes cobra's output and error writers toos.Stderr, which is right for help and usage, but it also sendssfdupes --versionthere. A version string is the most machine-read output a CLI has; scripts expect it on stdout. README §Design goal 4 says everything on stdout is machine-readable data, which a version string is.The shipped image can never report a real version.
.dockerignore:1excludes.git, soVERSION := $(shell git describe --tags --always --dirty ...)(Makefile:6) falls back todevinside the container built atDockerfile:52.docker run sfdupes --versiontherefore printsdevfor every image ever built, including release images.Also undocumented: README §Subcommands says "Three subcommands, all implemented" and the usage block lists only the three; neither
--versionnor-h/--helpappears anywhere, nor which stream they use.Definition of done
sfdupes --versionprints one line,sfdupes VERSION, to stdout, and exits 0. Help and usage stay on stderr.ARG VERSION=devand passes it through to the build ldflags, andscript/dockersupplies--build-arg VERSION=$(git describe --tags --always --dirty)so a locally built image reports the real tag. Do not un-exclude.gitfrom.dockerignore.--versionand--help, their output streams and their exit codes.--version, and that the exit code is 0.make checkgreen andmake dockersucceeds;docker run --rm sfdupes --versionprints a real version rather thandev.