diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index ccbb24eec3..dbb4201eca 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -66,9 +66,10 @@ OPTIONS: {{end}}{{end}} ` -var ( - gitCommit string // Git SHA1 commit hash of the release (set via linker flags) -) +// 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 var ( @@ -89,6 +90,7 @@ var defaultNodeConfig = node.DefaultConfig // This init function sets defaults so cmd/swarm can run alongside geth. func init() { + sv.GitCommit = gitCommit defaultNodeConfig.Name = clientIdentifier defaultNodeConfig.Version = sv.VersionWithCommit(gitCommit) defaultNodeConfig.P2P.ListenAddr = ":30399" diff --git a/swarm/version/version.go b/swarm/version/version.go index 15adf13fb9..9c72481104 100644 --- a/swarm/version/version.go +++ b/swarm/version/version.go @@ -41,8 +41,7 @@ var VersionWithMeta = func() string { 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 +// Git SHA1 commit hash of the release, will be set by main.init() function var GitCommit string // ArchiveVersion holds the textual version string used for Swarm archives. @@ -55,7 +54,6 @@ func ArchiveVersion(gitCommit string) string { } if len(gitCommit) >= 8 { vsn += "-" + gitCommit[:8] - GitCommit = gitCommit[:8] } return vsn } @@ -64,7 +62,6 @@ func VersionWithCommit(gitCommit string) string { vsn := Version if len(gitCommit) >= 8 { vsn += "-" + gitCommit[:8] - GitCommit = gitCommit[:8] } return vsn }