From ffc74391d5b14af149b74e11fb6f37d0812ad404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Wed, 25 Jul 2018 10:27:20 +0200 Subject: [PATCH] move version.go to top level package MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera --- core/commands/sysdiag.go | 6 +++--- core/commands/version.go | 6 +++--- core/core.go | 5 ++++- core/corehttp/commands.go | 8 ++++---- core/corehttp/gateway.go | 4 ++-- core/corehttp/gateway_test.go | 3 ++- core/corehttp/option_test.go | 6 +++--- docs/releases.md | 2 +- docs/windows.md | 2 +- repo/version.go => version.go | 4 ++-- 10 files changed, 25 insertions(+), 21 deletions(-) rename repo/version.go => version.go (81%) diff --git a/core/commands/sysdiag.go b/core/commands/sysdiag.go index 840772c22..8d3aa1343 100644 --- a/core/commands/sysdiag.go +++ b/core/commands/sysdiag.go @@ -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" @@ -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) }, } diff --git a/core/commands/version.go b/core/commands/version.go index b4084ce48..3d98d5279 100644 --- a/core/commands/version.go +++ b/core/commands/version.go @@ -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" @@ -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(), diff --git a/core/core.go b/core/core.go index fc853c947..dce5544a8 100644 --- a/core/core.go +++ b/core/core.go @@ -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" @@ -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" @@ -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. diff --git a/core/corehttp/commands.go b/core/corehttp/commands.go index ce602abf6..f779018b3 100644 --- a/core/corehttp/commands.go +++ b/core/corehttp/commands.go @@ -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" @@ -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) { @@ -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() diff --git a/core/corehttp/gateway.go b/core/corehttp/gateway.go index f9db2a23d..acdea180d 100644 --- a/core/corehttp/gateway.go +++ b/core/corehttp/gateway.go @@ -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" ) @@ -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) }) diff --git a/core/corehttp/gateway_test.go b/core/corehttp/gateway_test.go index 522b07927..86631a5f8 100644 --- a/core/corehttp/gateway_test.go +++ b/core/corehttp/gateway_test.go @@ -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" @@ -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) diff --git a/core/corehttp/option_test.go b/core/corehttp/option_test.go index ecc572eaa..22157618c 100644 --- a/core/corehttp/option_test.go +++ b/core/corehttp/option_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/ipfs/go-ipfs/repo" + version "github.com/ipfs/go-ipfs" ) type testcasecheckversion struct { @@ -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 @@ -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}, } diff --git a/docs/releases.md b/docs/releases.md index 54b49c531..f0edef37e 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -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 diff --git a/docs/windows.md b/docs/windows.md index 8e55fd0b3..2687805e2 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -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`. diff --git a/repo/version.go b/version.go similarity index 81% rename from repo/version.go rename to version.go index 2f0a135b3..37d5753d6 100644 --- a/repo/version.go +++ b/version.go @@ -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 + "/"