Compare commits

...

3 Commits

Author SHA1 Message Date
Denton Gentry
3eeff9e7f7 VERSION.txt: this is v1.38.1
Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2023-03-14 14:39:43 -07:00
David Anderson
6c0e6a5f4e version/mkversion: don't break on tagged go.mod entries
I thought our versioning scheme would make go.mod include a commit hash
even on stable builds. I was wrong. Fortunately, the rest of this code
wants anything that 'git rev-parse' understands (to convert it into a full
git hash), and tags qualify.

Signed-off-by: David Anderson <danderson@tailscale.com>
(cherry picked from commit 9ebab961c9)
2023-03-14 14:32:10 -07:00
Denton Gentry
10d462d321 VERSION.txt: this is v1.38.0
Signed-off-by: Denton Gentry <dgentry@tailscale.com>
2023-03-14 13:17:16 -07:00
2 changed files with 14 additions and 12 deletions

View File

@@ -1 +1 @@
1.37.0
1.38.1

View File

@@ -150,14 +150,14 @@ func InfoFrom(dir string) (VersionInfo, error) {
}
// Note, this mechanism doesn't correctly support go.mod replacements,
// or go workdirs. We only parse out the commit hash from go.mod's
// or go workdirs. We only parse out the commit ref from go.mod's
// "require" line, nothing else.
tailscaleHash, err := tailscaleModuleHash(modBs)
tailscaleRef, err := tailscaleModuleRef(modBs)
if err != nil {
return VersionInfo{}, err
}
v, err := infoFromCache(tailscaleHash, runner)
v, err := infoFromCache(tailscaleRef, runner)
if err != nil {
return VersionInfo{}, err
}
@@ -171,9 +171,10 @@ func InfoFrom(dir string) (VersionInfo, error) {
return mkOutput(v)
}
// tailscaleModuleHash returns the git hash of the 'require tailscale.com' line
// in the given go.mod bytes.
func tailscaleModuleHash(modBs []byte) (string, error) {
// tailscaleModuleRef returns the git ref of the 'require tailscale.com' line
// in the given go.mod bytes. The ref is either a short commit hash, or a git
// tag.
func tailscaleModuleRef(modBs []byte) (string, error) {
mod, err := modfile.Parse("go.mod", modBs, nil)
if err != nil {
return "", err
@@ -187,7 +188,8 @@ func tailscaleModuleHash(modBs []byte) (string, error) {
if i := strings.LastIndexByte(req.Mod.Version, '-'); i != -1 {
return req.Mod.Version[i+1:], nil
}
return "", fmt.Errorf("couldn't parse git hash from tailscale.com version %q", req.Mod.Version)
// If there are no dashes, the version is a tag.
return req.Mod.Version, nil
}
return "", fmt.Errorf("no require tailscale.com line in go.mod")
}
@@ -310,7 +312,7 @@ type verInfo struct {
// sentinel patch number.
const unknownPatchVersion = 9999999
func infoFromCache(shortHash string, runner dirRunner) (verInfo, error) {
func infoFromCache(ref string, runner dirRunner) (verInfo, error) {
cacheDir, err := os.UserCacheDir()
if err != nil {
return verInfo{}, fmt.Errorf("Getting user cache dir: %w", err)
@@ -324,16 +326,16 @@ func infoFromCache(shortHash string, runner dirRunner) (verInfo, error) {
}
}
if !r.ok("git", "cat-file", "-e", shortHash) {
if !r.ok("git", "cat-file", "-e", ref) {
if !r.ok("git", "fetch", "origin") {
return verInfo{}, fmt.Errorf("updating OSS repo failed")
}
}
hash, err := r.output("git", "rev-parse", shortHash)
hash, err := r.output("git", "rev-parse", ref)
if err != nil {
return verInfo{}, err
}
date, err := r.output("git", "log", "-n1", "--format=%ct", shortHash)
date, err := r.output("git", "log", "-n1", "--format=%ct", ref)
if err != nil {
return verInfo{}, err
}