MCPcopy Create free account
hub / github.com/codehamr/codehamr / isLocalBuild

Function isLocalBuild

cmd/codehamr/main.go:132–142  ·  view source on GitHub ↗

isLocalBuild reports whether the binary came from a working tree rather than an official release. `go run` leaves version "dev"; `make install` injects `git describe --tags --always --dirty`, so a dirty tree carries a "-dirty" suffix, a clean tree past the last tag the describe shape (v0.3.0-5-g5290

(version string)

Source from the content-addressed store, hash-verified

130// silently swap unreleased work for the last published release (its hash
131// never matches the manifest, so it always reads as "stale") on first launch.
132func isLocalBuild(version string) bool {
133 if version == "dev" || strings.HasSuffix(version, "-dirty") {
134 return true
135 }
136 // describe-with-commits: anything carrying a "-g<hex>" suffix.
137 if i := strings.LastIndex(version, "-g"); i >= 0 && isHex(version[i+2:]) {
138 return true
139 }
140 // bare `--always` short sha (tag-less clone): all-hex, no tag structure.
141 return len(version) >= 7 && isHex(version)
142}
143
144// isHex reports whether s is non-empty lowercase hex, the shape of a git
145// abbreviated commit hash.

Callers 2

TestIsLocalBuildFunction · 0.85
maybeSelfUpdateFunction · 0.85

Calls 1

isHexFunction · 0.85

Tested by 1

TestIsLocalBuildFunction · 0.68