@cryptotaxi247 / kubo / commits / f6f8d6857

version: don't print 'VERSION-' if no commit is specified

fixes #6022

Steven Allen committed Aug 27, 2019 at 23:31 UTC f6f8d68574945d565cdbadc39accd2aad4c309c4
3 files changed +19 -10
cmd/ipfs/daemon.go
+5 -1
@@ -726,7 +726,11 @@ func YesNoPrompt(prompt string) bool {
726 }
727
728 func printVersion() {
729 - fmt.Printf("go-ipfs version: %s-%s\n", version.CurrentVersionNumber, version.CurrentCommit)
729 + v := version.CurrentVersionNumber
730 + if version.CurrentCommit != "" {
731 + v += "-" + version.CurrentCommit
732 + }
733 + fmt.Printf("go-ipfs version: %s\n", v)
734 fmt.Printf("Repo version: %d\n", fsrepo.RepoVersion)
735 fmt.Printf("System version: %s\n", runtime.GOARCH+"/"+runtime.GOOS)
736 fmt.Printf("Golang version: %s\n", runtime.Version())
core/commands/version.go
+12 -8
@@ -54,21 +54,25 @@ var VersionCmd = &cmds.Command{
54 },
55 Encoders: cmds.EncoderMap{
56 cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, version *VersionOutput) error {
57 - commit, _ := req.Options[versionCommitOptionName].(bool)
58 - commitTxt := ""
59 - if commit {
60 - commitTxt = "-" + version.Commit
61 - }
62 -
57 all, _ := req.Options[versionAllOptionName].(bool)
58 if all {
65 - out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
59 + ver := version.Version
60 + if version.Commit != "" {
61 + ver += "-" + version.Commit
62 + }
63 + out := fmt.Sprintf("go-ipfs version: %s\n"+
64 "Repo version: %s\nSystem version: %s\nGolang version: %s\n",
67 - version.Version, version.Commit, version.Repo, version.System, version.Golang)
65 + ver, version.Repo, version.System, version.Golang)
66 fmt.Fprint(w, out)
67 return nil
68 }
69
70 + commit, _ := req.Options[versionCommitOptionName].(bool)
71 + commitTxt := ""
72 + if commit && version.Commit != "" {
73 + commitTxt = "-" + version.Commit
74 + }
75 +
76 repo, _ := req.Options[versionRepoOptionName].(bool)
77 if repo {
78 fmt.Fprintln(w, version.Repo)
core/core.go
+2 -1
@@ -12,6 +12,7 @@ package core
12 import (
13 "context"
14 "io"
15 + "path"
16
17 "github.com/ipfs/go-filestore"
18 version "github.com/ipfs/go-ipfs"
@@ -54,7 +55,7 @@ import (
55 var log = logging.Logger("core")
56
57 func init() {
57 - identify.ClientVersion = "go-ipfs/" + version.CurrentVersionNumber + "/" + version.CurrentCommit
58 + identify.ClientVersion = path.Join("go-ipfs", version.CurrentVersionNumber, version.CurrentCommit)
59 }
60
61 // IpfsNode is IPFS Core module. It represents an IPFS instance.