From: Matt Joiner Date: Mon, 15 Jan 2024 03:51:13 +0000 (+1100) Subject: Fix anacrolix/torrent version detection X-Git-Tag: v1.53.3~4 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=25f0b1af9c9b971acb0ce10fde49a51d8ef25c7f;p=btrtrc.git Fix anacrolix/torrent version detection Still doesn't work for devel builds of main however. https://github.com/anacrolix/torrent/issues/889#issuecomment-1891242553 --- diff --git a/version/version.go b/version/version.go index 3d3ae550..66483b68 100644 --- a/version/version.go +++ b/version/version.go @@ -5,6 +5,7 @@ import ( "fmt" "reflect" "runtime/debug" + "strings" ) var ( @@ -32,9 +33,11 @@ func init() { if buildInfo, ok := debug.ReadBuildInfo(); ok { mainPath = buildInfo.Main.Path mainVersion = buildInfo.Main.Version + thisModule := "" // Note that if the main module is the same as this module, we get a version of "(devel)". for _, dep := range append(buildInfo.Deps, &buildInfo.Main) { - if dep.Path == thisPkg { + if strings.HasPrefix(thisPkg, dep.Path) && len(dep.Path) >= len(thisModule) { + thisModule = dep.Path torrentVersion = dep.Version } }