Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
20 changes: 12 additions & 8 deletions core/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package core
import (
"context"
"io"
"path"

"github.com/ipfs/go-filestore"
version "github.com/ipfs/go-ipfs"
Expand Down Expand Up @@ -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.
Expand Down