Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs/kubo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 4de5eaad5fbb
Choose a base ref
...
head repository: ipfs/kubo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0f909cb2ebd6
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Oct 17, 2015

  1. adds the option to see the current git commit with `ipfs version --co…

    …mmit`
    
    License: MIT
    Signed-off-by: Caio Alonso <caio@caioalonso.com>
    caioalonso committed Oct 17, 2015
    Copy the full SHA
    e05f2d3 View commit details

Commits on Oct 18, 2015

  1. Merge pull request #1853 from CaioAlonso/show-commit-hash

    Adds the option to see the current git commit with `ipfs version --commit`
    jbenet committed Oct 18, 2015
    Copy the full SHA
    0f909cb View commit details
Showing with 23 additions and 4 deletions.
  1. +3 −1 Makefile
  2. +3 −1 cmd/ipfs/Makefile
  3. +15 −2 core/commands/version.go
  4. +2 −0 repo/config/version.go
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ else
go_test=go test
endif

commit = `git rev-parse --short HEAD`
ldflags = "-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(commit)"

all:
# no-op. try:
@@ -24,7 +26,7 @@ install:
cd cmd/ipfs && go install

build:
cd cmd/ipfs && go build -i
cd cmd/ipfs && go build -i -ldflags=$(ldflags)

nofuse:
cd cmd/ipfs && go install -tags nofuse
4 changes: 3 additions & 1 deletion cmd/ipfs/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
all: install
commit = `git rev-parse --short HEAD`
ldflags = "-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(commit)"

build:
go build
go build -ldflags=$(ldflags)

install: build
go install
17 changes: 15 additions & 2 deletions core/commands/version.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (

type VersionOutput struct {
Version string
Commit string
}

var VersionCmd = &cmds.Command{
@@ -21,24 +22,36 @@ var VersionCmd = &cmds.Command{

Options: []cmds.Option{
cmds.BoolOption("number", "n", "Only show the version number"),
cmds.BoolOption("commit", "Show the commit hash"),
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetOutput(&VersionOutput{
Version: config.CurrentVersionNumber,
Commit: config.CurrentCommit,
})
},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v := res.Output().(*VersionOutput)

commit, found, err := res.Request().Option("commit").Bool()
commitTxt := ""
if err != nil {
return nil, err
}
if found && commit {
commitTxt = "-" + v.Commit
}

number, found, err := res.Request().Option("number").Bool()
if err != nil {
return nil, err
}
if found && number {
return strings.NewReader(fmt.Sprintln(v.Version)), nil
return strings.NewReader(fmt.Sprintln(v.Version + commitTxt)), nil
}
return strings.NewReader(fmt.Sprintf("ipfs version %s\n", v.Version)), nil

return strings.NewReader(fmt.Sprintf("ipfs version %s%s\n", v.Version, commitTxt)), nil
},
},
Type: VersionOutput{},
2 changes: 2 additions & 0 deletions repo/config/version.go
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ import (

// CurrentVersionNumber is the current application's version literal
const CurrentVersionNumber = "0.3.8-dev"
// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var CurrentCommit string

// Version regulates checking if the most recent version is run
type Version struct {