Skip to content

Commit

Permalink
Fix anacrolix/torrent version detection
Browse files Browse the repository at this point in the history
Still doesn't work for devel builds of main however.

#889 (comment)
  • Loading branch information
anacrolix committed Jan 15, 2024
1 parent a1105a0 commit 25f0b1a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"reflect"
"runtime/debug"
"strings"
)

var (
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 25f0b1a

Please sign in to comment.