On Thu, Jul 11, 2024 at 12:30 PM Johannes Kastl <mail@johannes-kastl.de> wrote:
Hi all,

I found regclient today and packaged it:

> https://github.com/regclient/regclient
> https://build.opensuse.org/package/show/home:ojkastl_buildservice:Branch_Virtualization_containers/regclient

Unfortunately, the version output is broken, as the package uses the
go debug.buildinfo internally:

> https://github.com/regclient/regclient/blob/410091ab2d89e76ffa039f36e5695477a5629c13/internal/version/version_buildinfo.go#L42

$ regctl version
VCSTag:     0.6.1
VCSRef:     unknown
VCSCommit:  unknown
VCSState:   unknown
VCSDate:    unknown
Platform:   linux/amd64
GoVer:      go1.22.5
GoCompiler: gc
$


Hello Johannes,

The regctl repository tags differ in some way from most Go repositories. The one difference I can point to is that tag v0.6.1 is not contained by any branch, main in particular. It may not be possible for debug.buildinfo to infer a version under those conditions.

regclient> git checkout --detach v0.6.1

regclient> git branch --contains tags/v0.6.1
* (HEAD detached at v0.6.1)
(notably, master/main is not in this list)

# build binary up one level to prevent dirty VCS tree
regclient> go build -o ../regctl-bin ./cmd/regctl/ && ../regctl-bin version
VCSTag:     (devel)
VCSRef:     766ee6291f882778207ff42207f9ca8b1da54e57
VCSCommit:  766ee6291f882778207ff42207f9ca8b1da54e57
VCSState:   clean
VCSDate:    2024-05-14T13:18:19Z
Platform:   linux/amd64
GoVer:      go1.22.4
GoCompiler: gc

regclient> go version -m ../regctl-bin
../regctl-bin: go1.22.4
path    github.com/regclient/regclient/cmd/regctl
mod     github.com/regclient/regclient  (devel)
dep     github.com/docker/libtrust      v0.0.0-20160708172513-aabc10ec26b7      h1:(snip)
dep     github.com/klauspost/compress   v1.17.8 h1:(snip)
dep     github.com/opencontainers/go-digest     v1.0.0  h1:(snip)
dep     github.com/sirupsen/logrus      v1.9.3  h1:(snip)
dep     github.com/spf13/cobra  v1.8.0  h1:(snip)
dep     github.com/spf13/pflag  v1.0.5  h1:(snip)
dep     github.com/ulikunitz/xz v0.5.12 h1:(snip)
dep     golang.org/x/sys        v0.20.0 h1:(snip)
dep     golang.org/x/term       v0.20.0 h1:(snip)
build   -buildmode=exe
build   -compiler=gc
build   DefaultGODEBUG=httplaxcontentlength=1,httpmuxgo121=1,panicnil=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
build   CGO_ENABLED=1
build   CGO_CFLAGS=
build   CGO_CPPFLAGS=
build   CGO_CXXFLAGS=
build   CGO_LDFLAGS=
build   GOARCH=amd64
build   GOOS=linux
build   GOAMD64=v1
build   vcs=git
build   vcs.revision=766ee6291f882778207ff42207f9ca8b1da54e57
build   vcs.time=2024-05-14T13:18:19Z
build   vcs.modified=true

regclient> git branch --contains tags/v0.6.1
* (HEAD detached at v0.6.1)
(notably, main is not in this list)

regclient> git switch main
Previous HEAD position was 766ee62 Release v0.6.1
Switched to branch 'main'
Your branch is up to date with 'origin/main'.

regclient> git branch --contains tags/v0.6.1
(empty)

regclient> git branch --contains v0.6.1
(empty)


For comparison, the tags in the hugo repository behave as we would expect:

hugo> git checkout --detach v0.128.2
HEAD is now at de36c1a9 releaser: Bump versions for release of 0.128.2

hugo> git branch --contains tags/v0.128.2
* (HEAD detached at v0.128.2)
  master

hugo> go build -o ../hugo-bin && ../hugo-bin version
hugo v0.128.2-de36c1a95d28595d8243fd8b891665b069ed0850 linux/amd64 BuildDate=2024-07-04T08:13:25Z


--
Jeff Kowalczyk
Software Engineer, Go Developer Experience
SUSE Linux
Email jkowalczyk@suse.com
Timezone US/Pacific
http://suse.com