swarm/version: fixed gitCommit variable

This commit is contained in:
Vlad 2019-01-23 18:52:33 +04:00
parent 3d6f32bbd8
commit 652395195d
2 changed files with 6 additions and 7 deletions

View file

@ -66,9 +66,10 @@ OPTIONS:
{{end}}{{end}} {{end}}{{end}}
` `
var ( // Git SHA1 commit hash of the release (set via linker flags)
gitCommit string // Git SHA1 commit hash of the release (set via linker flags) // 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
//declare a few constant error messages, useful for later error check comparisons in test //declare a few constant error messages, useful for later error check comparisons in test
var ( var (
@ -89,6 +90,7 @@ var defaultNodeConfig = node.DefaultConfig
// This init function sets defaults so cmd/swarm can run alongside geth. // This init function sets defaults so cmd/swarm can run alongside geth.
func init() { func init() {
sv.GitCommit = gitCommit
defaultNodeConfig.Name = clientIdentifier defaultNodeConfig.Name = clientIdentifier
defaultNodeConfig.Version = sv.VersionWithCommit(gitCommit) defaultNodeConfig.Version = sv.VersionWithCommit(gitCommit)
defaultNodeConfig.P2P.ListenAddr = ":30399" defaultNodeConfig.P2P.ListenAddr = ":30399"

View file

@ -41,8 +41,7 @@ var VersionWithMeta = func() string {
return v return v
}() }()
// this variable will be assigned if corresponding parameter is passed with install, but not with test // Git SHA1 commit hash of the release, will be set by main.init() function
// e.g.: go install -ldflags "-X main.gitCommit=ed1312d01b19e04ef578946226e5d8069d5dfd5a" ./cmd/swarm
var GitCommit string var GitCommit string
// ArchiveVersion holds the textual version string used for Swarm archives. // ArchiveVersion holds the textual version string used for Swarm archives.
@ -55,7 +54,6 @@ 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
} }
@ -64,7 +62,6 @@ 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
} }