Skip to content

Commit

Permalink
move version.go to top level package
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Aug 9, 2018
1 parent d52091f commit ffc7439
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 21 deletions.
6 changes: 3 additions & 3 deletions core/commands/sysdiag.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path"
"runtime"

version "github.com/ipfs/go-ipfs"
cmds "github.com/ipfs/go-ipfs/commands"
"github.com/ipfs/go-ipfs/repo"

manet "gx/ipfs/QmV6FjemM1K8oXjrvuq3wuVWWoU2TLDPmNnKrxHzY3v6Ai/go-multiaddr-net"
sysi "gx/ipfs/QmZRjKbHa6DenStpQJFiaPcEwkZqrx7TH6xTf342LDU3qM/go-sysinfo"
Expand Down Expand Up @@ -57,8 +57,8 @@ Prints out information about your computer to aid in easier debugging.
return
}

info["ipfs_version"] = repo.CurrentVersionNumber
info["ipfs_commit"] = repo.CurrentCommit
info["ipfs_version"] = version.CurrentVersionNumber
info["ipfs_commit"] = version.CurrentCommit
res.SetOutput(info)
},
}
Expand Down
6 changes: 3 additions & 3 deletions core/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"runtime"
"strings"

version "github.com/ipfs/go-ipfs"
cmds "github.com/ipfs/go-ipfs/commands"
e "github.com/ipfs/go-ipfs/core/commands/e"
repo "github.com/ipfs/go-ipfs/repo"
fsrepo "github.com/ipfs/go-ipfs/repo/fsrepo"

"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
Expand Down Expand Up @@ -36,8 +36,8 @@ var VersionCmd = &cmds.Command{
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetOutput(&VersionOutput{
Version: repo.CurrentVersionNumber,
Commit: repo.CurrentCommit,
Version: version.CurrentVersionNumber,
Commit: version.CurrentCommit,
Repo: fmt.Sprint(fsrepo.RepoVersion),
System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here
Golang: runtime.Version(),
Expand Down
5 changes: 4 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strings"
"time"

version "github.com/ipfs/go-ipfs"
rp "github.com/ipfs/go-ipfs/exchange/reprovide"
filestore "github.com/ipfs/go-ipfs/filestore"
mount "github.com/ipfs/go-ipfs/fuse/mount"
Expand All @@ -44,6 +45,8 @@ import (
logging "gx/ipfs/QmRREK2CAZ5Re2Bd9zZFG6FeYDppUWt5cMgsoUEp3ktgSr/go-log"
floodsub "gx/ipfs/QmRXefkwjreRT6XfYh3Ag4hsVnWBbpcUicGJPcg8TWbhBK/go-libp2p-floodsub"
goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
bitswap "gx/ipfs/QmNQQEYL3Vpj4beteqyeRpVpivuX1wBP6Q5GZMdBPPTV3S/go-bitswap"
bsnet "gx/ipfs/QmNQQEYL3Vpj4beteqyeRpVpivuX1wBP6Q5GZMdBPPTV3S/go-bitswap/network"
mamask "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter"
mafilter "gx/ipfs/QmSW4uNHbvQia8iZDXzbwjiyHQtnyo9aFqfQAMasj3TJ6Y/go-maddr-filter"
libp2p "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p"
Expand Down Expand Up @@ -94,7 +97,7 @@ const (
)

func init() {
identify.ClientVersion = "go-ipfs/" + repo.CurrentVersionNumber + "/" + repo.CurrentCommit
identify.ClientVersion = "go-ipfs/" + version.CurrentVersionNumber + "/" + version.CurrentCommit
}

// IpfsNode is IPFS Core module. It represents an IPFS instance.
Expand Down
8 changes: 4 additions & 4 deletions core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
"strconv"
"strings"

version "github.com/ipfs/go-ipfs"
oldcmds "github.com/ipfs/go-ipfs/commands"
core "github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/core"
corecommands "github.com/ipfs/go-ipfs/core/commands"
repo "github.com/ipfs/go-ipfs/repo"

path "gx/ipfs/QmPqCBrmkm7jNfYi7xFS7mUZsrN6DEumBMrxLnL7axNJx1/go-path"
cmds "gx/ipfs/QmbWGdyATxHpmbDC2z7zMNnmPmiHCRXS5f2vyxBfgz8bVb/go-ipfs-cmds"
Expand Down Expand Up @@ -78,7 +78,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
for h, v := range nc.API.HTTPHeaders {
c.Headers[h] = v
}
c.Headers["Server"] = []string{"go-ipfs/" + repo.CurrentVersionNumber}
c.Headers["Server"] = []string{"go-ipfs/" + version.CurrentVersionNumber}
}

func addCORSDefaults(c *cmdsHttp.ServerConfig) {
Expand Down Expand Up @@ -153,7 +153,7 @@ func CommandsROOption(cctx oldcmds.Context) ServeOption {

// CheckVersionOption returns a ServeOption that checks whether the client ipfs version matches. Does nothing when the user agent string does not contain `/go-ipfs/`
func CheckVersionOption() ServeOption {
daemonVersion := repo.ApiVersion
daemonVersion := version.ApiVersion

return ServeOption(func(n *core.IpfsNode, l net.Listener, parent *http.ServeMux) (*http.ServeMux, error) {
mux := http.NewServeMux()
Expand Down
4 changes: 2 additions & 2 deletions core/corehttp/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"net"
"net/http"

version "github.com/ipfs/go-ipfs"
core "github.com/ipfs/go-ipfs/core"
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
repo "github.com/ipfs/go-ipfs/repo"

id "gx/ipfs/QmUDzeFgYrRmHL2hUB6NZmqcBVQtUzETwmFRUc9onfSSHr/go-libp2p/p2p/protocol/identify"
)
Expand Down Expand Up @@ -41,7 +41,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
func VersionOption() ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.HandleFunc("/version", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Commit: %s\n", repo.CurrentCommit)
fmt.Fprintf(w, "Commit: %s\n", version.CurrentCommit)
fmt.Fprintf(w, "Client Version: %s\n", id.ClientVersion)
fmt.Fprintf(w, "Protocol Version: %s\n", id.LibP2PVersion)
})
Expand Down
3 changes: 2 additions & 1 deletion core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"
"time"

version "github.com/ipfs/go-ipfs"
core "github.com/ipfs/go-ipfs/core"
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
namesys "github.com/ipfs/go-ipfs/namesys"
Expand Down Expand Up @@ -545,7 +546,7 @@ func TestGoGetSupport(t *testing.T) {
}

func TestVersion(t *testing.T) {
repo.CurrentCommit = "theshortcommithash"
version.CurrentCommit = "theshortcommithash"

ns := mockNamesys{}
ts, _ := newTestServerAndNode(t, ns)
Expand Down
6 changes: 3 additions & 3 deletions core/corehttp/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http/httptest"
"testing"

"github.com/ipfs/go-ipfs/repo"
version "github.com/ipfs/go-ipfs"
)

type testcasecheckversion struct {
Expand All @@ -20,7 +20,7 @@ type testcasecheckversion struct {

func (tc testcasecheckversion) body() string {
if !tc.shouldHandle && tc.responseBody == "" {
return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, repo.ApiVersion, tc.userAgent)
return fmt.Sprintf("%s (%s != %s)\n", errAPIVersionMismatch, version.ApiVersion, tc.userAgent)
}

return tc.responseBody
Expand All @@ -30,7 +30,7 @@ func TestCheckVersionOption(t *testing.T) {
tcs := []testcasecheckversion{
{"/go-ipfs/0.1/", APIPath + "/test/", false, "", http.StatusBadRequest},
{"/go-ipfs/0.1/", APIPath + "/version", true, "check!", http.StatusOK},
{repo.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK},
{version.ApiVersion, APIPath + "/test", true, "check!", http.StatusOK},
{"Mozilla Firefox/no go-ipfs node", APIPath + "/test", true, "check!", http.StatusOK},
{"/go-ipfs/0.1/", "/webui", true, "check!", http.StatusOK},
}
Expand Down
2 changes: 1 addition & 1 deletion docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ will be allowed up to release day.
- [ ] publish gx version with `gx release`, as per [gx release guidelines](https://github.com/whyrusleeping/gx#publishing-and-releasing)

## Post-Release
- [ ] bump version string in `repo/version.go` to `vX.Y.Z-dev`
- [ ] Bump version string in `repo/version.go` to `vX.Y.Z-dev`
- [ ] Upload the final release to the github releases page: https://github.com/ipfs/go-ipfs/releases
- Communication
- [ ] Create the release issue
Expand Down
2 changes: 1 addition & 1 deletion docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ We need the `git` commit hash to be included in our build so that in the extreme

Finally, we'll build and test `ipfs` itself.
```
go install -ldflags="-X "github.com/ipfs/go-ipfs/repo".CurrentCommit=%SHA%"
go install -ldflags="-X "github.com/ipfs/go-ipfs".CurrentCommit=%SHA%"
%GOPATH%\bin\ipfs.exe version --all
```
You can check that the ipfs output versions match with `go version` and `git rev-parse --short HEAD`.
Expand Down
4 changes: 2 additions & 2 deletions repo/version.go → version.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package repo
package ipfs

// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var CurrentCommit string

// CurrentVersionNumber is the current application's version literal
const CurrentVersionNumber = "0.4.17-dev"
const CurrentVersionNumber = "0.4.18-dev"

const ApiVersion = "/go-ipfs/" + CurrentVersionNumber + "/"

0 comments on commit ffc7439

Please sign in to comment.