swarm/version: commit version added

This commit is contained in:
Vlad 2019-01-23 16:34:20 +04:00
parent f91312dbdb
commit 3d6f32bbd8
2 changed files with 10 additions and 0 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/swarm/log" "github.com/ethereum/go-ethereum/swarm/log"
"github.com/ethereum/go-ethereum/swarm/pot" "github.com/ethereum/go-ethereum/swarm/pot"
sv "github.com/ethereum/go-ethereum/swarm/version"
) )
/* /*
@ -552,6 +553,9 @@ func (k *Kademlia) string() string {
var rows []string var rows []string
rows = append(rows, "=========================================================================") rows = append(rows, "=========================================================================")
if len(sv.GitCommit) > 0 {
rows = append(rows, fmt.Sprintf("commit hash: %s", sv.GitCommit))
}
rows = append(rows, fmt.Sprintf("%v KΛÐΞMLIΛ hive: queen's address: %x", time.Now().UTC().Format(time.UnixDate), k.BaseAddr()[:3])) rows = append(rows, fmt.Sprintf("%v KΛÐΞMLIΛ hive: queen's address: %x", time.Now().UTC().Format(time.UnixDate), k.BaseAddr()[:3]))
rows = append(rows, fmt.Sprintf("population: %d (%d), NeighbourhoodSize: %d, MinBinSize: %d, MaxBinSize: %d", k.conns.Size(), k.addrs.Size(), k.NeighbourhoodSize, k.MinBinSize, k.MaxBinSize)) rows = append(rows, fmt.Sprintf("population: %d (%d), NeighbourhoodSize: %d, MinBinSize: %d, MaxBinSize: %d", k.conns.Size(), k.addrs.Size(), k.NeighbourhoodSize, k.MinBinSize, k.MaxBinSize))

View file

@ -41,6 +41,10 @@ var VersionWithMeta = func() string {
return v return v
}() }()
// this variable will be assigned if corresponding parameter is passed with install, but not with test
// e.g.: go install -ldflags "-X main.gitCommit=ed1312d01b19e04ef578946226e5d8069d5dfd5a" ./cmd/swarm
var GitCommit string
// ArchiveVersion holds the textual version string used for Swarm archives. // ArchiveVersion holds the textual version string used for Swarm archives.
// e.g. "0.3.0-dea1ce05" for stable releases, or // e.g. "0.3.0-dea1ce05" for stable releases, or
// "0.3.1-unstable-21c059b6" for unstable releases // "0.3.1-unstable-21c059b6" for unstable releases
@ -51,6 +55,7 @@ func ArchiveVersion(gitCommit string) string {
} }
if len(gitCommit) >= 8 { if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8] vsn += "-" + gitCommit[:8]
GitCommit = gitCommit[:8]
} }
return vsn return vsn
} }
@ -59,6 +64,7 @@ func VersionWithCommit(gitCommit string) string {
vsn := Version vsn := Version
if len(gitCommit) >= 8 { if len(gitCommit) >= 8 {
vsn += "-" + gitCommit[:8] vsn += "-" + gitCommit[:8]
GitCommit = gitCommit[:8]
} }
return vsn return vsn
} }