gopass
gopass copied to clipboard
[FR] Include commit hash in `gopass version`
Summary
gopass version
currently displays the version string as 1.9.0-git+HEAD
, which provides some indication of the version being used, but does not include critical information when debugging, such as the commit hash. Including this would simplify bug reports.
Steps To Reproduce
➜ gopass version
gopass 1.9.0-git+HEAD go1.14.2 linux amd64
<root> - gpg 2.2.20 - git 2.26.2 - fs 0.1.0
Available Crypto Backends: gpgcli, plain, xc
Available RCS Backends: gitcli, noop
Available Storage Backends: fs, inmem
Expected behavior
Provide the git sha in the version output, either by changing the format of the version string, or by providing a new row. For reference, some ideas:
➜ git describe --long
v1.9.0-8-g22fd3b9
gopass 1.9.0-git+22fd3b9
Environment
➜ git log -1 --format='%H'
22fd3b92ed6982e3f357b7e0f0ec355d22cac524
➜ ./gopass version
gopass 1.9.0-git+HEAD go1.14.2 linux amd64
<root> - gpg 2.2.20 - git 2.26.2 - fs 0.1.0
Available Crypto Backends: gpgcli, plain, xc
Available RCS Backends: gitcli, noop
Available Storage Backends: fs, inmem
➜ uname -srm
Linux 5.6.10-arch1-1 x86_64
This might be a limitation in upstream goreleaser. In the past we had our patched version create a COMMIT file to allow users downloading the tarball to have the correct commit hash set.
I'm not sure if there is a way to have this with vanilla goreleaser, but one way or another I'd like to fix this.
I wouldn't necessarily label this as a bug, it's really a feature request.
I have an idea on how to handle this cleanly via Make, and will try to send a CL up this weekend.
In some cases this works but not in other.
When building with make
from a git checkout it would correctly pass the commit hash to go and display that in the extended version information.
But the version parsing itself was broken since the last release when we started adding the v prefix in the VERSION file. This should be fixed with 56e617385c022d6ac2bf478ebf96b37622edd322.
However when building from a source tarball, which doesn't contain .git
this shouldn't work because there is no way to get the commit hash. And I don't think this can be solved without some file containing this information.
Briefly looking at it I couldn't figure out how to make vanilla goreleaser include this information in the source tarball.