WIP: rebase for 2026-05-18 #7
+8
-1
@@ -24,7 +24,14 @@ var stringLazy = sync.OnceValue(func() string {
|
|||||||
if extraGitCommitStamp != "" {
|
if extraGitCommitStamp != "" {
|
||||||
fmt.Fprintf(&ret, " other commit: %s\n", extraGitCommitStamp)
|
fmt.Fprintf(&ret, " other commit: %s\n", extraGitCommitStamp)
|
||||||
}
|
}
|
||||||
fmt.Fprintf(&ret, " go version: %s\n", runtime.Version())
|
if tsGoRev := tailscaleToolchainRev(); tsGoRev != "" {
|
||||||
|
if len(tsGoRev) > 10 {
|
||||||
|
tsGoRev = tsGoRev[:10]
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&ret, " go version: %s (tailscale/go %s)\n", runtime.Version(), tsGoRev)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(&ret, " go version: %s\n", runtime.Version())
|
||||||
|
}
|
||||||
return strings.TrimSpace(ret.String())
|
return strings.TrimSpace(ret.String())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+17
-11
@@ -312,6 +312,11 @@ type Meta struct {
|
|||||||
// GitCommitTime is the commit time of the git commit in GitCommit.
|
// GitCommitTime is the commit time of the git commit in GitCommit.
|
||||||
GitCommitTime string `json:"gitCommitTime,omitempty"`
|
GitCommitTime string `json:"gitCommitTime,omitempty"`
|
||||||
|
|
||||||
|
// TailscaleGoGitHash is the git commit hash from
|
||||||
|
// https://github.com/tailscale/go used to build this binary, if built
|
||||||
|
// with the Tailscale Go toolchain. Otherwise it is empty.
|
||||||
|
TailscaleGoGitHash string `json:"tailscaleGoGitHash,omitempty"`
|
||||||
|
|
||||||
// Cap is the current Tailscale capability version. It's a monotonically
|
// Cap is the current Tailscale capability version. It's a monotonically
|
||||||
// incrementing integer that's incremented whenever a new capability is
|
// incrementing integer that's incremented whenever a new capability is
|
||||||
// added.
|
// added.
|
||||||
@@ -324,17 +329,18 @@ var getMeta lazy.SyncValue[Meta]
|
|||||||
func GetMeta() Meta {
|
func GetMeta() Meta {
|
||||||
return getMeta.Get(func() Meta {
|
return getMeta.Get(func() Meta {
|
||||||
return Meta{
|
return Meta{
|
||||||
MajorMinorPatch: majorMinorPatch(),
|
MajorMinorPatch: majorMinorPatch(),
|
||||||
Short: Short(),
|
Short: Short(),
|
||||||
Long: Long(),
|
Long: Long(),
|
||||||
GitCommitTime: getEmbeddedInfo().commitTime,
|
GitCommitTime: getEmbeddedInfo().commitTime,
|
||||||
GitCommit: gitCommit(),
|
GitCommit: gitCommit(),
|
||||||
GitDirty: gitDirty(),
|
GitDirty: gitDirty(),
|
||||||
OSVariant: osVariant(),
|
OSVariant: osVariant(),
|
||||||
ExtraGitCommit: extraGitCommitStamp,
|
ExtraGitCommit: extraGitCommitStamp,
|
||||||
IsDev: isDev(),
|
IsDev: isDev(),
|
||||||
UnstableBranch: IsUnstableBuild(),
|
UnstableBranch: IsUnstableBuild(),
|
||||||
Cap: int(tailcfg.CurrentCapabilityVersion),
|
TailscaleGoGitHash: tailscaleToolchainRev(),
|
||||||
|
Cap: int(tailcfg.CurrentCapabilityVersion),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,23 @@ var getEmbeddedInfo = sync.OnceValue(func() embeddedInfo {
|
|||||||
return ret
|
return ret
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// tailscaleToolchainRev returns the git hash of the Tailscale Go toolchain
|
||||||
|
// used to build this binary, if any. It is read separately from getEmbeddedInfo
|
||||||
|
// because that function discards build info when VCS fields are missing (e.g.
|
||||||
|
// in test binaries), but the toolchain rev is still present.
|
||||||
|
var tailscaleToolchainRev = sync.OnceValue(func() string {
|
||||||
|
bi, ok := debug.ReadBuildInfo()
|
||||||
|
if !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
for _, s := range bi.Settings {
|
||||||
|
if s.Key == "tailscale.toolchain.rev" {
|
||||||
|
return s.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
})
|
||||||
|
|
||||||
func gitCommit() string {
|
func gitCommit() string {
|
||||||
if gitCommitStamp != "" {
|
if gitCommitStamp != "" {
|
||||||
return gitCommitStamp
|
return gitCommitStamp
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
|
|
||||||
package version
|
package version
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"tailscale.com/util/cibuild"
|
||||||
|
)
|
||||||
|
|
||||||
func TestIsValidLongWithTwoRepos(t *testing.T) {
|
func TestIsValidLongWithTwoRepos(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@@ -26,6 +32,26 @@ func TestIsValidLongWithTwoRepos(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTailscaleToolchainRev(t *testing.T) {
|
||||||
|
out, err := exec.Command("go", "env", "GOROOT").Output()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("go env GOROOT: %v", err)
|
||||||
|
}
|
||||||
|
goRoot := strings.TrimSpace(string(out))
|
||||||
|
isTsgo := strings.Contains(goRoot, "/.cache/tsgo/")
|
||||||
|
if !cibuild.On() && !isTsgo {
|
||||||
|
t.Skip("skipping; not in CI and not using the Tailscale Go toolchain")
|
||||||
|
}
|
||||||
|
if !isTailscaleGo {
|
||||||
|
t.Skip("skipping; not built with tailscale_go build tag")
|
||||||
|
}
|
||||||
|
rev := tailscaleToolchainRev()
|
||||||
|
if rev == "" {
|
||||||
|
t.Fatal("tailscale.toolchain.rev is empty in build info; expected non-empty when using tsgo")
|
||||||
|
}
|
||||||
|
t.Logf("tailscale.toolchain.rev = %s", rev)
|
||||||
|
}
|
||||||
|
|
||||||
func TestPrepExeNameForCmp(t *testing.T) {
|
func TestPrepExeNameForCmp(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
exe string
|
exe string
|
||||||
|
|||||||
Reference in New Issue
Block a user