Commit f6f8d685 authored by Steven Allen's avatar Steven Allen

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

fixes #6022
parent 32d54a0a
......@@ -726,7 +726,11 @@ func YesNoPrompt(prompt string) bool {
}
func printVersion() {
fmt.Printf("go-ipfs version: %s-%s\n", version.CurrentVersionNumber, version.CurrentCommit)
v := version.CurrentVersionNumber
if version.CurrentCommit != "" {
v += "-" + version.CurrentCommit
}
fmt.Printf("go-ipfs version: %s\n", v)
fmt.Printf("Repo version: %d\n", fsrepo.RepoVersion)
fmt.Printf("System version: %s\n", runtime.GOARCH+"/"+runtime.GOOS)
fmt.Printf("Golang version: %s\n", runtime.Version())
......
......@@ -54,21 +54,25 @@ var VersionCmd = &cmds.Command{
},
Encoders: cmds.EncoderMap{
cmds.Text: cmds.MakeTypedEncoder(func(req *cmds.Request, w io.Writer, version *VersionOutput) error {
commit, _ := req.Options[versionCommitOptionName].(bool)
commitTxt := ""
if commit {
commitTxt = "-" + version.Commit
}
all, _ := req.Options[versionAllOptionName].(bool)
if all {
out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
ver := version.Version
if version.Commit != "" {
ver += "-" + version.Commit
}
out := fmt.Sprintf("go-ipfs version: %s\n"+
"Repo version: %s\nSystem version: %s\nGolang version: %s\n",
version.Version, version.Commit, version.Repo, version.System, version.Golang)
ver, version.Repo, version.System, version.Golang)
fmt.Fprint(w, out)
return nil
}
commit, _ := req.Options[versionCommitOptionName].(bool)
commitTxt := ""
if commit && version.Commit != "" {
commitTxt = "-" + version.Commit
}
repo, _ := req.Options[versionRepoOptionName].(bool)
if repo {
fmt.Fprintln(w, version.Repo)
......
......@@ -12,6 +12,7 @@ package core
import (
"context"
"io"
"path"
"github.com/ipfs/go-filestore"
version "github.com/ipfs/go-ipfs"
......@@ -54,7 +55,7 @@ import (
var log = logging.Logger("core")
func init() {
identify.ClientVersion = "go-ipfs/" + version.CurrentVersionNumber + "/" + version.CurrentCommit
identify.ClientVersion = path.Join("go-ipfs", version.CurrentVersionNumber, version.CurrentCommit)
}
// IpfsNode is IPFS Core module. It represents an IPFS instance.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment