From 7dbe280c7a217bee971ebee712e8e2bd3c93a48d Mon Sep 17 00:00:00 2001 From: Hannah Howard Date: Tue, 4 Aug 2020 07:55:24 -0700 Subject: [PATCH] Release infrastructure (#81) * style(imports): fix import formatting Fix import formatting via script. Also add script for import fixes and release log * docs(CHANGELOG): add changelog, contributing Add the changelog and a contributing guidelines doc --- CHANGELOG.md | 94 +++++++ CONTRIBUTING.md | 94 +++++++ README.md | 2 +- cidset/cidset.go | 3 +- cidset/cidset_test.go | 3 +- impl/graphsync.go | 9 +- impl/graphsync_test.go | 23 +- ipldutil/traverser_test.go | 5 +- linktracker/linktracker.go | 3 +- linktracker/linktracker_test.go | 5 +- message/message.go | 8 +- message/message_test.go | 4 +- message/pb/message.pb.go | 5 +- messagequeue/messagequeue.go | 4 +- messagequeue/messagequeue_test.go | 8 +- metadata/metadata.go | 3 +- network/interface.go | 4 +- network/libp2p_impl.go | 3 +- network/libp2p_impl_test.go | 7 +- peermanager/peermanager_test.go | 3 +- peermanager/peermessagemanager.go | 4 +- peermanager/peermessagemanager_test.go | 7 +- requestmanager/asyncloader/asyncloader.go | 4 +- .../asyncloader/asyncloader_test.go | 8 +- .../loadattemptqueue/loadattemptqueue.go | 3 +- .../loadattemptqueue/loadattemptqueue_test.go | 5 +- .../responsecache/responsecache.go | 10 +- .../responsecache/responsecache_test.go | 7 +- .../unverifiedblockstore_test.go | 3 +- requestmanager/executor/executor.go | 9 +- requestmanager/executor/executor_test.go | 11 +- requestmanager/hooks/hooks_test.go | 9 +- requestmanager/hooks/requesthooks.go | 3 +- requestmanager/requestmanager.go | 16 +- requestmanager/requestmanager_test.go | 22 +- requestmanager/responsecollector_test.go | 5 +- requestmanager/testloader/asyncloader.go | 7 +- responsemanager/hooks/blockhooks.go | 3 +- responsemanager/hooks/hooks_test.go | 9 +- responsemanager/hooks/listeners.go | 3 +- responsemanager/hooks/requesthook.go | 3 +- responsemanager/hooks/requestupdatehooks.go | 3 +- .../peerresponsemanager.go | 3 +- .../peerresponsemanager/peerresponsesender.go | 12 +- .../peerresponsesender_test.go | 10 +- responsemanager/queryexecutor.go | 7 +- .../responsebuilder/responsebuilder.go | 3 +- .../responsebuilder/responsebuilder_test.go | 7 +- responsemanager/responsemanager.go | 10 +- responsemanager/responsemanager_test.go | 13 +- responsemanager/runtraversal/runtraversal.go | 3 +- .../runtraversal/runtraversal_test.go | 6 +- scripts/fiximports | 13 + scripts/mkreleaselog | 245 ++++++++++++++++++ selectorvalidator/selectorvalidator.go | 3 +- selectorvalidator/selectorvalidator_test.go | 3 +- testutil/testchain.go | 3 +- testutil/testnodes_test.go | 3 +- testutil/testutil.go | 6 +- 59 files changed, 631 insertions(+), 163 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100755 scripts/fiximports create mode 100755 scripts/mkreleaselog diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..8b1ed70e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,94 @@ +# go-graphsync changelog + +# go-graphysnc 0.0.1-filecoin + +Initial tagged release for early version of filecoin + +### Changelog + +Initial feature set including parallel requests, selectors, basic architecture, +etc. -- changelog not tracked due to lack of go.mod + +# go-graphsync 0.0.2 + +Bug fix release. Fix message sizes to not overflow limits. + +### Changelog + +- github.com/ipfs/go-graphsync: + - Limit Response Size ([ipfs/go-graphsync#37](https://github.com/ipfs/go-graphsync/pull/37)) + +### Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| hannahhoward | 2 | +295/-52 | 5 | + +# go-graphsync 0.0.3 + +Bug fix release. Fix issues issues with message queue. + +### Changelog + +- github.com/ipfs/go-graphsync: + - fix(messagequeue): no retry after queue shutdown ([ipfs/go-graphsync#38](https://github.com/ipfs/go-graphsync/pull/38)) + +### Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| hannahhoward | 1 | +70/-1 | 2 | + +# go-graphsync 0.0.4 + +Initial release to incorporate into go-data-transfer module. + +Implements request authorization, request hooks, default valdiation policy, etc + +### Changelog + +- github.com/ipfs/go-graphsync: + - Add DAG Protobuf Support ([ipfs/go-graphsync#51](https://github.com/ipfs/go-graphsync/pull/51)) + - Add response hooks ([ipfs/go-graphsync#50](https://github.com/ipfs/go-graphsync/pull/50)) + - Request hooks ([ipfs/go-graphsync#49](https://github.com/ipfs/go-graphsync/pull/49)) + - Add a default validation policy ([ipfs/go-graphsync#48](https://github.com/ipfs/go-graphsync/pull/48)) + - Send user extensions in request ([ipfs/go-graphsync#47](https://github.com/ipfs/go-graphsync/pull/47)) + - Revert "Merge pull request #44 from ipfs/chore/update-peertaskqueue" + - Update peertaskqueue ([ipfs/go-graphsync#44](https://github.com/ipfs/go-graphsync/pull/44)) + - Refactor file organization ([ipfs/go-graphsync#43](https://github.com/ipfs/go-graphsync/pull/43)) + - feat(graphsync): support extension protocol ([ipfs/go-graphsync#42](https://github.com/ipfs/go-graphsync/pull/42)) + - Bump go-ipld-prime to 092ea9a7696d ([ipfs/go-graphsync#41](https://github.com/ipfs/go-graphsync/pull/41)) + - Fix some typo ([ipfs/go-graphsync#40](https://github.com/ipfs/go-graphsync/pull/40)) + +### Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| hannahhoward | 12 | +3040/-1516 | 103 | +| Hannah Howard | 2 | +253/-321 | 3 | +| Dirk McCormick | 1 | +47/-33 | 4 | +| Edgar Lee | 1 | +36/-20 | 8 | +| Alexey | 1 | +15/-15 | 1 | + +# go-graphsync v0.0.5 + +Minor release -- update task queue and add some documentation + +### Changelog + +- github.com/ipfs/go-graphsync: + - feat: update the peer task queue ([ipfs/go-graphsync#54](https://github.com/ipfs/go-graphsync/pull/54)) + - docs(readme): document the storeutil package in the readme ([ipfs/go-graphsync#52](https://github.com/ipfs/go-graphsync/pull/52)) + +### Contributors + +| Contributor | Commits | Lines ± | Files Changed | +|-------------|---------|---------|---------------| +| Steven Allen | 2 | +68/-49 | 5 | + +### 🙌🏽 Want to contribute? + +Would you like to contribute to this repo and don’t know how? Here are a few places you can get started: + +- Check out the [Contributing Guidelines](https://github.com/ipfs/go-graphsync/blob/master/CONTRIBUTING.md) +- Look for issues with the `good-first-issue` label in [go-graphsync](https://github.com/ipfs/go-graphsync/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+label%3A%22e-good-first-issue%22+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..c9c1f901 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,94 @@ +# Contributing to this repo + +First, thank you for your interest in contributing to this project! Before you pick up your first issue and start +changing code, please: + +1. Review all documentation for the module you're interested in. +1. Look through the [issues for this repo](https://github.com/ipfs/go-graphsync/issues) for relevant discussions. +1. If you have questions about an issue, post a comment in the issue. +1. If you want to submit changes that aren't covered by an issue, file a new one with your proposal, outlining what problem you found/feature you want to implement, and how you intend to implement a solution. + +For best results, before submitting a PR, make sure: +1. It has met all acceptance criteria for the issue. +1. It addresses only the one issue and does not make other, irrelevant changes. +1. Your code conforms to our coding style guide. +1. You have adequate test coverage (this should be indicated by CI results anyway). +1. If you like, check out [current PRs](https://github.com/ipfs/go-graphsync/pulls) to see how others do it. + +Special Note: +If editing README.md, please conform to the [standard readme specification](https://github.com/RichardLitt/standard-readme/blob/master/spec.md). + +### PR Process + +Active development of `go-graphsync` occurs on the `master` branch. All PRs should be made to the `master` branch, which is the default branch on Github. + +Before a PR can be merged to `master`, it must: +1. Pass continuous integration. +1. Be rebased and up to date with the `master` branch +1. Be approved by at least one maintainer + +When merging normal PRs to `master`, always use squash and merge to maintain a linear commit history. + +### Release Process + +When creating a new full release, branch off master with a branch named release/*version-number*, where *version-number* is the ultimate tag you intend to create. + +Continue to develop on master and merge commits to your release branch as neccesary till the release is ready. + +When the release is ready, tag it, then merge the branch back into master so that it is part of the version history of master. Delete the release branch. + +### Hotfix Process + +Hot-fixes operate just like release branches, except they are branched off an existing tag and should be named hotfix/*version-number*. When ready, they receive their own tag and then are merged back to master, then deleted. + +For external reference, his git flow and release process is essentially the [OneFlow git workflow](https://www.endoflineblog.com/oneflow-a-git-branching-model-and-workflow) + +Following the release of Filecoin Mainnet, this library will following a semantic versioning scheme for tagged releases. + +### Testing + +- All new code should be accompanied by unit tests. Prefer focused unit tests to integration tests for thorough validation of behaviour. Existing code is not necessarily a good model, here. + +### Conventions and Style + +#### Imports +We use the following import ordering. +``` +import ( + [stdlib packages, alpha-sorted] + + [external packages] + + [go-graphsync packages] +) +``` + +Where a package name does not match its directory name, an explicit alias is expected (`goimports` will add this for you). + +Example: + +```go +import ( + "context" + "testing" + + cmds "github.com/ipfs/go-ipfs-cmds" + cid "github.com/ipfs/go-cid" + ipld "github.com/ipfs/go-ipld-format" + "github.com/stretchr/testify/assert" + + datatransfer "github.com/filecoin-project/go-data-transfer" + + "github.com/filecoin-project/go-fil-markets/filestore/file" +) +``` + +You can run `script/fiximports` to put all your code in the desired format + +#### Comments + +Comments are a communication to other developers (including your future self) to help them understand and maintain code. Good comments describe the _intent_ of the code, without repeating the procedures directly. + +- A `TODO:` comment describes a change that is desired but could not be immediately implemented. It must include a reference to a GitHub issue outlining whatever prevents the thing being done now (which could just be a matter of priority). +- A `NOTE:` comment indicates an aside, some background info, or ideas for future improvement, rather than the intent of the current code. It's often fine to document such ideas alongside the code rather than an issue (at the loss of a space for discussion). +- `FIXME`, `HACK`, `XXX` and similar tags indicating that some code is to be avoided in favour of `TODO`, `NOTE` or some straight prose. diff --git a/README.md b/README.md index 6d8d9c6b..f9baff8f 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ PRs are welcome! Before doing anything heavy, checkout the [Graphsync Architecture](docs/architecture.md) -Small note: If editing the Readme, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. +See our [Contributing Guidelines](https://github.com/ipfs/go-graphsync/blob/master/CONTRIBUTING.md) for more info. ## License diff --git a/cidset/cidset.go b/cidset/cidset.go index e6efb361..49f3d8f9 100644 --- a/cidset/cidset.go +++ b/cidset/cidset.go @@ -4,10 +4,11 @@ import ( "errors" "github.com/ipfs/go-cid" - "github.com/ipfs/go-graphsync/ipldutil" "github.com/ipld/go-ipld-prime/fluent" cidlink "github.com/ipld/go-ipld-prime/linking/cid" basicnode "github.com/ipld/go-ipld-prime/node/basic" + + "github.com/ipfs/go-graphsync/ipldutil" ) // EncodeCidSet encodes a cid set into bytes for the do-no-send-cids extension diff --git a/cidset/cidset_test.go b/cidset/cidset_test.go index 17f6e5dd..abb1f0d4 100644 --- a/cidset/cidset_test.go +++ b/cidset/cidset_test.go @@ -4,8 +4,9 @@ import ( "testing" "github.com/ipfs/go-cid" - "github.com/ipfs/go-graphsync/testutil" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync/testutil" ) func TestDecodeEncodeCidSet(t *testing.T) { diff --git a/impl/graphsync.go b/impl/graphsync.go index 9828b6ba..2af7abc3 100644 --- a/impl/graphsync.go +++ b/impl/graphsync.go @@ -3,6 +3,11 @@ package graphsync import ( "context" + logging "github.com/ipfs/go-log" + "github.com/ipfs/go-peertaskqueue" + ipld "github.com/ipld/go-ipld-prime" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/ipfs/go-graphsync" gsmsg "github.com/ipfs/go-graphsync/message" "github.com/ipfs/go-graphsync/messagequeue" @@ -16,10 +21,6 @@ import ( "github.com/ipfs/go-graphsync/responsemanager/peerresponsemanager" "github.com/ipfs/go-graphsync/responsemanager/persistenceoptions" "github.com/ipfs/go-graphsync/selectorvalidator" - logging "github.com/ipfs/go-log" - "github.com/ipfs/go-peertaskqueue" - ipld "github.com/ipld/go-ipld-prime" - "github.com/libp2p/go-libp2p-core/peer" ) var log = logging.Logger("graphsync") diff --git a/impl/graphsync_test.go b/impl/graphsync_test.go index 80d8a47e..7fad0a12 100644 --- a/impl/graphsync_test.go +++ b/impl/graphsync_test.go @@ -14,11 +14,6 @@ import ( "testing" "time" - basicnode "github.com/ipld/go-ipld-prime/node/basic" - "github.com/stretchr/testify/require" - - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-blockservice" "github.com/ipfs/go-cid" @@ -33,21 +28,23 @@ import ( unixfile "github.com/ipfs/go-unixfs/file" "github.com/ipfs/go-unixfs/importer/balanced" ihelper "github.com/ipfs/go-unixfs/importer/helpers" - - "github.com/ipfs/go-graphsync" - - "github.com/ipfs/go-graphsync/cidset" - "github.com/ipfs/go-graphsync/ipldutil" - gsmsg "github.com/ipfs/go-graphsync/message" - gsnet "github.com/ipfs/go-graphsync/network" - "github.com/ipfs/go-graphsync/testutil" ipld "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector" ipldselector "github.com/ipld/go-ipld-prime/traversal/selector" "github.com/ipld/go-ipld-prime/traversal/selector/builder" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/peer" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" + "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/cidset" + "github.com/ipfs/go-graphsync/ipldutil" + gsmsg "github.com/ipfs/go-graphsync/message" + gsnet "github.com/ipfs/go-graphsync/network" + "github.com/ipfs/go-graphsync/testutil" ) func TestMakeRequestToNetwork(t *testing.T) { diff --git a/ipldutil/traverser_test.go b/ipldutil/traverser_test.go index 16c649ca..3bb11fec 100644 --- a/ipldutil/traverser_test.go +++ b/ipldutil/traverser_test.go @@ -6,8 +6,6 @@ import ( "testing" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/testutil" ipld "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" basicnode "github.com/ipld/go-ipld-prime/node/basic" @@ -15,6 +13,9 @@ import ( "github.com/ipld/go-ipld-prime/traversal/selector" "github.com/ipld/go-ipld-prime/traversal/selector/builder" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/testutil" ) func TestTraverser(t *testing.T) { diff --git a/linktracker/linktracker.go b/linktracker/linktracker.go index 8f18ffcf..eafe073c 100644 --- a/linktracker/linktracker.go +++ b/linktracker/linktracker.go @@ -1,8 +1,9 @@ package linktracker import ( - "github.com/ipfs/go-graphsync" "github.com/ipld/go-ipld-prime" + + "github.com/ipfs/go-graphsync" ) // LinkTracker records links being traversed to determine useful information diff --git a/linktracker/linktracker_test.go b/linktracker/linktracker_test.go index 8e94ad95..af9745c9 100644 --- a/linktracker/linktracker_test.go +++ b/linktracker/linktracker_test.go @@ -4,10 +4,11 @@ import ( "math/rand" "testing" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/testutil" "github.com/ipld/go-ipld-prime" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/testutil" ) type request struct { diff --git a/message/message.go b/message/message.go index 82f3fa1b..d8c4d6f3 100644 --- a/message/message.go +++ b/message/message.go @@ -4,15 +4,15 @@ import ( "fmt" "io" + ggio "github.com/gogo/protobuf/io" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" + cid "github.com/ipfs/go-cid" "github.com/ipld/go-ipld-prime" + "github.com/libp2p/go-libp2p-core/network" - ggio "github.com/gogo/protobuf/io" - cid "github.com/ipfs/go-cid" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/ipldutil" pb "github.com/ipfs/go-graphsync/message/pb" - "github.com/libp2p/go-libp2p-core/network" ) // IsTerminalSuccessCode returns true if the response code indicates the diff --git a/message/message_test.go b/message/message_test.go index b14bfec9..28d8e0b2 100644 --- a/message/message_test.go +++ b/message/message_test.go @@ -7,12 +7,12 @@ import ( "testing" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" + cid "github.com/ipfs/go-cid" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" "github.com/stretchr/testify/require" - cid "github.com/ipfs/go-cid" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/ipldutil" "github.com/ipfs/go-graphsync/testutil" ) diff --git a/message/pb/message.pb.go b/message/pb/message.pb.go index 39a4b048..131b94e4 100644 --- a/message/pb/message.pb.go +++ b/message/pb/message.pb.go @@ -5,11 +5,12 @@ package graphsync_message_pb import ( fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/messagequeue/messagequeue.go b/messagequeue/messagequeue.go index 4ec81394..e94d307b 100644 --- a/messagequeue/messagequeue.go +++ b/messagequeue/messagequeue.go @@ -6,11 +6,11 @@ import ( "time" blocks "github.com/ipfs/go-block-format" + logging "github.com/ipfs/go-log" + "github.com/libp2p/go-libp2p-core/peer" gsmsg "github.com/ipfs/go-graphsync/message" gsnet "github.com/ipfs/go-graphsync/network" - logging "github.com/ipfs/go-log" - "github.com/libp2p/go-libp2p-core/peer" ) var log = logging.Logger("graphsync") diff --git a/messagequeue/messagequeue_test.go b/messagequeue/messagequeue_test.go index 541f8478..f2951d73 100644 --- a/messagequeue/messagequeue_test.go +++ b/messagequeue/messagequeue_test.go @@ -8,15 +8,15 @@ import ( "testing" "time" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/testutil" + basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" + "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" gsmsg "github.com/ipfs/go-graphsync/message" gsnet "github.com/ipfs/go-graphsync/network" - basicnode "github.com/ipld/go-ipld-prime/node/basic" - "github.com/libp2p/go-libp2p-core/peer" + "github.com/ipfs/go-graphsync/testutil" ) type fakeMessageNetwork struct { diff --git a/metadata/metadata.go b/metadata/metadata.go index 6acb80d3..15f8363a 100644 --- a/metadata/metadata.go +++ b/metadata/metadata.go @@ -1,10 +1,11 @@ package metadata import ( - "github.com/ipfs/go-graphsync/ipldutil" "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/fluent" basicnode "github.com/ipld/go-ipld-prime/node/basic" + + "github.com/ipfs/go-graphsync/ipldutil" ) // Item is a single link traversed in a repsonse diff --git a/network/interface.go b/network/interface.go index ae0bddf0..450882bb 100644 --- a/network/interface.go +++ b/network/interface.go @@ -3,10 +3,10 @@ package network import ( "context" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/protocol" + + gsmsg "github.com/ipfs/go-graphsync/message" ) var ( diff --git a/network/libp2p_impl.go b/network/libp2p_impl.go index 13db1eef..a54a3a42 100644 --- a/network/libp2p_impl.go +++ b/network/libp2p_impl.go @@ -7,13 +7,14 @@ import ( "time" ggio "github.com/gogo/protobuf/io" - gsmsg "github.com/ipfs/go-graphsync/message" logging "github.com/ipfs/go-log" "github.com/libp2p/go-libp2p-core/helpers" "github.com/libp2p/go-libp2p-core/host" "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" ma "github.com/multiformats/go-multiaddr" + + gsmsg "github.com/ipfs/go-graphsync/message" ) var log = logging.Logger("graphsync_network") diff --git a/network/libp2p_impl_test.go b/network/libp2p_impl_test.go index a775027f..089733e5 100644 --- a/network/libp2p_impl_test.go +++ b/network/libp2p_impl_test.go @@ -6,14 +6,15 @@ import ( "testing" "time" - "github.com/ipfs/go-graphsync" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/ipfs/go-graphsync/testutil" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" "github.com/libp2p/go-libp2p-core/peer" mocknet "github.com/libp2p/go-libp2p/p2p/net/mock" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/testutil" ) // Receiver is an interface for receiving messages from the GraphSyncNetwork. diff --git a/peermanager/peermanager_test.go b/peermanager/peermanager_test.go index 6086a41f..1d155adc 100644 --- a/peermanager/peermanager_test.go +++ b/peermanager/peermanager_test.go @@ -4,8 +4,9 @@ import ( "context" "testing" - "github.com/ipfs/go-graphsync/testutil" "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync/testutil" ) type fakePeerProcess struct { diff --git a/peermanager/peermessagemanager.go b/peermanager/peermessagemanager.go index 48ff8409..9e51a8d8 100644 --- a/peermanager/peermessagemanager.go +++ b/peermanager/peermessagemanager.go @@ -3,10 +3,10 @@ package peermanager import ( "context" - "github.com/ipfs/go-block-format" + blocks "github.com/ipfs/go-block-format" + "github.com/libp2p/go-libp2p-core/peer" gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/libp2p/go-libp2p-core/peer" ) // PeerQueue is a process that sends messages to a peer diff --git a/peermanager/peermessagemanager_test.go b/peermanager/peermessagemanager_test.go index f1ee79fb..40ee6da7 100644 --- a/peermanager/peermessagemanager_test.go +++ b/peermanager/peermessagemanager_test.go @@ -7,13 +7,14 @@ import ( "time" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/ipfs/go-graphsync/testutil" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/testutil" ) type messageSent struct { diff --git a/requestmanager/asyncloader/asyncloader.go b/requestmanager/asyncloader/asyncloader.go index 73f38219..b86d2dc1 100644 --- a/requestmanager/asyncloader/asyncloader.go +++ b/requestmanager/asyncloader/asyncloader.go @@ -6,14 +6,14 @@ import ( "io/ioutil" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" + "github.com/ipld/go-ipld-prime" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/metadata" "github.com/ipfs/go-graphsync/requestmanager/asyncloader/loadattemptqueue" "github.com/ipfs/go-graphsync/requestmanager/asyncloader/responsecache" "github.com/ipfs/go-graphsync/requestmanager/asyncloader/unverifiedblockstore" "github.com/ipfs/go-graphsync/requestmanager/types" - "github.com/ipld/go-ipld-prime" ) type loaderMessage interface { diff --git a/requestmanager/asyncloader/asyncloader_test.go b/requestmanager/asyncloader/asyncloader_test.go index a8ccb10a..3715acdb 100644 --- a/requestmanager/asyncloader/asyncloader_test.go +++ b/requestmanager/asyncloader/asyncloader_test.go @@ -8,14 +8,14 @@ import ( "time" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/metadata" - "github.com/ipfs/go-graphsync/requestmanager/types" + ipld "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/metadata" + "github.com/ipfs/go-graphsync/requestmanager/types" "github.com/ipfs/go-graphsync/testutil" - ipld "github.com/ipld/go-ipld-prime" ) func TestAsyncLoadInitialLoadSucceedsLocallyPresent(t *testing.T) { diff --git a/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue.go b/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue.go index 6ef030a0..092cd0a3 100644 --- a/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue.go +++ b/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue.go @@ -3,9 +3,10 @@ package loadattemptqueue import ( "errors" + "github.com/ipld/go-ipld-prime" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/requestmanager/types" - "github.com/ipld/go-ipld-prime" ) // LoadRequest is a request to load the given link for the given request id, diff --git a/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue_test.go b/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue_test.go index e1af70a9..5f26a6fe 100644 --- a/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue_test.go +++ b/requestmanager/asyncloader/loadattemptqueue/loadattemptqueue_test.go @@ -7,11 +7,12 @@ import ( "testing" "time" + ipld "github.com/ipld/go-ipld-prime" + "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/requestmanager/types" "github.com/ipfs/go-graphsync/testutil" - ipld "github.com/ipld/go-ipld-prime" - "github.com/stretchr/testify/require" ) func TestAsyncLoadInitialLoadSucceeds(t *testing.T) { diff --git a/requestmanager/asyncloader/responsecache/responsecache.go b/requestmanager/asyncloader/responsecache/responsecache.go index 1ce33155..af05fb9e 100644 --- a/requestmanager/asyncloader/responsecache/responsecache.go +++ b/requestmanager/asyncloader/responsecache/responsecache.go @@ -4,14 +4,14 @@ import ( "fmt" "sync" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/metadata" - logging "github.com/ipfs/go-log" - blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync/linktracker" + logging "github.com/ipfs/go-log" "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" + + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/linktracker" + "github.com/ipfs/go-graphsync/metadata" ) var log = logging.Logger("graphsync") diff --git a/requestmanager/asyncloader/responsecache/responsecache_test.go b/requestmanager/asyncloader/responsecache/responsecache_test.go index a2caf471..674a2014 100644 --- a/requestmanager/asyncloader/responsecache/responsecache_test.go +++ b/requestmanager/asyncloader/responsecache/responsecache_test.go @@ -6,14 +6,13 @@ import ( "testing" blocks "github.com/ipfs/go-block-format" - "github.com/ipfs/go-graphsync" + ipld "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/metadata" "github.com/ipfs/go-graphsync/testutil" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - - ipld "github.com/ipld/go-ipld-prime" ) type fakeUnverifiedBlockStore struct { diff --git a/requestmanager/asyncloader/unverifiedblockstore/unverifiedblockstore_test.go b/requestmanager/asyncloader/unverifiedblockstore/unverifiedblockstore_test.go index 876ea65a..283301cb 100644 --- a/requestmanager/asyncloader/unverifiedblockstore/unverifiedblockstore_test.go +++ b/requestmanager/asyncloader/unverifiedblockstore/unverifiedblockstore_test.go @@ -6,11 +6,10 @@ import ( "testing" "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/stretchr/testify/require" "github.com/ipfs/go-graphsync/testutil" - - cidlink "github.com/ipld/go-ipld-prime/linking/cid" ) func TestVerifyBlockPresent(t *testing.T) { diff --git a/requestmanager/executor/executor.go b/requestmanager/executor/executor.go index 30c96478..8ce4cb4e 100644 --- a/requestmanager/executor/executor.go +++ b/requestmanager/executor/executor.go @@ -7,16 +7,17 @@ import ( "sync/atomic" "github.com/ipfs/go-cid" + ipld "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/ipld/go-ipld-prime/traversal" + peer "github.com/libp2p/go-libp2p-core/peer" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/cidset" "github.com/ipfs/go-graphsync/ipldutil" gsmsg "github.com/ipfs/go-graphsync/message" "github.com/ipfs/go-graphsync/requestmanager/hooks" "github.com/ipfs/go-graphsync/requestmanager/types" - ipld "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - "github.com/ipld/go-ipld-prime/traversal" - peer "github.com/libp2p/go-libp2p-core/peer" ) // AsyncLoadFn is a function which given a request id and an ipld.Link, returns diff --git a/requestmanager/executor/executor_test.go b/requestmanager/executor/executor_test.go index 0db6d0e7..9d446382 100644 --- a/requestmanager/executor/executor_test.go +++ b/requestmanager/executor/executor_test.go @@ -9,6 +9,12 @@ import ( "time" "github.com/ipfs/go-cid" + "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + basicnode "github.com/ipld/go-ipld-prime/node/basic" + peer "github.com/libp2p/go-libp2p-core/peer" + "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/cidset" "github.com/ipfs/go-graphsync/ipldutil" @@ -18,11 +24,6 @@ import ( "github.com/ipfs/go-graphsync/requestmanager/testloader" "github.com/ipfs/go-graphsync/requestmanager/types" "github.com/ipfs/go-graphsync/testutil" - "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" - peer "github.com/libp2p/go-libp2p-core/peer" - "github.com/stretchr/testify/require" ) type configureLoaderFn func(p peer.ID, requestID graphsync.RequestID, tbc *testutil.TestBlockChain, fal *testloader.FakeAsyncLoader, startStop [2]int) diff --git a/requestmanager/hooks/hooks_test.go b/requestmanager/hooks/hooks_test.go index addd0c00..823fef0f 100644 --- a/requestmanager/hooks/hooks_test.go +++ b/requestmanager/hooks/hooks_test.go @@ -5,15 +5,16 @@ import ( "math/rand" "testing" - "github.com/ipfs/go-graphsync" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/ipfs/go-graphsync/requestmanager/hooks" - "github.com/ipfs/go-graphsync/testutil" "github.com/ipld/go-ipld-prime" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" peer "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/requestmanager/hooks" + "github.com/ipfs/go-graphsync/testutil" ) func TestRequestHookProcessing(t *testing.T) { diff --git a/requestmanager/hooks/requesthooks.go b/requestmanager/hooks/requesthooks.go index f85f29e1..7d057198 100644 --- a/requestmanager/hooks/requesthooks.go +++ b/requestmanager/hooks/requesthooks.go @@ -2,9 +2,10 @@ package hooks import ( "github.com/hannahhoward/go-pubsub" - "github.com/ipfs/go-graphsync" "github.com/ipld/go-ipld-prime/traversal" peer "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync" ) // OutgoingRequestHooks is a set of incoming request hooks that can be processed diff --git a/requestmanager/requestmanager.go b/requestmanager/requestmanager.go index 55b03ade..6acd39ef 100644 --- a/requestmanager/requestmanager.go +++ b/requestmanager/requestmanager.go @@ -6,21 +6,21 @@ import ( "fmt" "sync/atomic" + blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-cid" - "github.com/ipfs/go-graphsync/cidset" - "github.com/ipfs/go-graphsync/requestmanager/executor" - "github.com/ipfs/go-graphsync/requestmanager/hooks" + logging "github.com/ipfs/go-log" + "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/libp2p/go-libp2p-core/peer" - blocks "github.com/ipfs/go-block-format" "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/cidset" ipldutil "github.com/ipfs/go-graphsync/ipldutil" gsmsg "github.com/ipfs/go-graphsync/message" "github.com/ipfs/go-graphsync/metadata" + "github.com/ipfs/go-graphsync/requestmanager/executor" + "github.com/ipfs/go-graphsync/requestmanager/hooks" "github.com/ipfs/go-graphsync/requestmanager/types" - logging "github.com/ipfs/go-log" - "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - "github.com/libp2p/go-libp2p-core/peer" ) var log = logging.Logger("graphsync") diff --git a/requestmanager/requestmanager_test.go b/requestmanager/requestmanager_test.go index 61f47561..ccd73a5d 100644 --- a/requestmanager/requestmanager_test.go +++ b/requestmanager/requestmanager_test.go @@ -7,23 +7,19 @@ import ( "testing" "time" - "github.com/ipfs/go-graphsync/cidset" - "github.com/ipfs/go-graphsync/requestmanager/testloader" - - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/requestmanager/hooks" - "github.com/ipfs/go-graphsync/requestmanager/types" + blocks "github.com/ipfs/go-block-format" + "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" - "github.com/ipfs/go-graphsync/metadata" - - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - - "github.com/ipld/go-ipld-prime" - - blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/cidset" gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/metadata" + "github.com/ipfs/go-graphsync/requestmanager/hooks" + "github.com/ipfs/go-graphsync/requestmanager/testloader" + "github.com/ipfs/go-graphsync/requestmanager/types" "github.com/ipfs/go-graphsync/testutil" ) diff --git a/requestmanager/responsecollector_test.go b/requestmanager/responsecollector_test.go index db90a7c2..c543157e 100644 --- a/requestmanager/responsecollector_test.go +++ b/requestmanager/responsecollector_test.go @@ -6,11 +6,12 @@ import ( "testing" "time" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/testutil" ipld "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + "github.com/ipfs/go-graphsync/testutil" ) func TestBufferingResponseProgress(t *testing.T) { diff --git a/requestmanager/testloader/asyncloader.go b/requestmanager/testloader/asyncloader.go index 2a068e83..34813dfd 100644 --- a/requestmanager/testloader/asyncloader.go +++ b/requestmanager/testloader/asyncloader.go @@ -6,13 +6,14 @@ import ( "testing" blocks "github.com/ipfs/go-block-format" + "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/metadata" "github.com/ipfs/go-graphsync/requestmanager/types" "github.com/ipfs/go-graphsync/testutil" - "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - "github.com/stretchr/testify/require" ) type requestKey struct { diff --git a/responsemanager/hooks/blockhooks.go b/responsemanager/hooks/blockhooks.go index 62a0352b..28b3b296 100644 --- a/responsemanager/hooks/blockhooks.go +++ b/responsemanager/hooks/blockhooks.go @@ -2,8 +2,9 @@ package hooks import ( "github.com/hannahhoward/go-pubsub" - "github.com/ipfs/go-graphsync" peer "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync" ) // ErrPaused indicates a request should stop processing, but only cause it's paused diff --git a/responsemanager/hooks/hooks_test.go b/responsemanager/hooks/hooks_test.go index 273a4f45..18d27ffb 100644 --- a/responsemanager/hooks/hooks_test.go +++ b/responsemanager/hooks/hooks_test.go @@ -6,15 +6,16 @@ import ( "math/rand" "testing" - "github.com/ipfs/go-graphsync" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/ipfs/go-graphsync/responsemanager/hooks" - "github.com/ipfs/go-graphsync/testutil" "github.com/ipld/go-ipld-prime" basicnode "github.com/ipld/go-ipld-prime/node/basic" "github.com/ipld/go-ipld-prime/traversal/selector/builder" peer "github.com/libp2p/go-libp2p-core/peer" "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/responsemanager/hooks" + "github.com/ipfs/go-graphsync/testutil" ) type fakePersistenceOptions struct { diff --git a/responsemanager/hooks/listeners.go b/responsemanager/hooks/listeners.go index 72cf58b3..52aaae5c 100644 --- a/responsemanager/hooks/listeners.go +++ b/responsemanager/hooks/listeners.go @@ -2,8 +2,9 @@ package hooks import ( "github.com/hannahhoward/go-pubsub" - "github.com/ipfs/go-graphsync" peer "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync" ) // CompletedResponseListeners is a set of listeners for completed responses diff --git a/responsemanager/hooks/requesthook.go b/responsemanager/hooks/requesthook.go index 74273936..46e2fba5 100644 --- a/responsemanager/hooks/requesthook.go +++ b/responsemanager/hooks/requesthook.go @@ -4,10 +4,11 @@ import ( "errors" "github.com/hannahhoward/go-pubsub" - "github.com/ipfs/go-graphsync" "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/traversal" peer "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync" ) // PersistenceOptions is an interface for getting loaders by name diff --git a/responsemanager/hooks/requestupdatehooks.go b/responsemanager/hooks/requestupdatehooks.go index b53f727e..117962bd 100644 --- a/responsemanager/hooks/requestupdatehooks.go +++ b/responsemanager/hooks/requestupdatehooks.go @@ -2,8 +2,9 @@ package hooks import ( "github.com/hannahhoward/go-pubsub" - "github.com/ipfs/go-graphsync" peer "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync" ) // RequestUpdatedHooks manages and runs hooks for request updates diff --git a/responsemanager/peerresponsemanager/peerresponsemanager.go b/responsemanager/peerresponsemanager/peerresponsemanager.go index 5100175d..a6632139 100644 --- a/responsemanager/peerresponsemanager/peerresponsemanager.go +++ b/responsemanager/peerresponsemanager/peerresponsemanager.go @@ -3,8 +3,9 @@ package peerresponsemanager import ( "context" - "github.com/ipfs/go-graphsync/peermanager" "github.com/libp2p/go-libp2p-core/peer" + + "github.com/ipfs/go-graphsync/peermanager" ) // PeerSenderFactory provides a function that will create a PeerResponseSender. diff --git a/responsemanager/peerresponsemanager/peerresponsesender.go b/responsemanager/peerresponsemanager/peerresponsesender.go index 8831434f..4212770d 100644 --- a/responsemanager/peerresponsemanager/peerresponsesender.go +++ b/responsemanager/peerresponsemanager/peerresponsesender.go @@ -4,19 +4,17 @@ import ( "context" "sync" - "github.com/ipfs/go-graphsync" - "github.com/ipfs/go-graphsync/peermanager" - - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - + blocks "github.com/ipfs/go-block-format" logging "github.com/ipfs/go-log" "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/libp2p/go-libp2p-core/peer" - blocks "github.com/ipfs/go-block-format" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/linktracker" gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/peermanager" "github.com/ipfs/go-graphsync/responsemanager/responsebuilder" - "github.com/libp2p/go-libp2p-core/peer" ) const ( diff --git a/responsemanager/peerresponsemanager/peerresponsesender_test.go b/responsemanager/peerresponsemanager/peerresponsesender_test.go index 179693d1..902fa9af 100644 --- a/responsemanager/peerresponsemanager/peerresponsesender_test.go +++ b/responsemanager/peerresponsemanager/peerresponsesender_test.go @@ -7,15 +7,15 @@ import ( "testing" "time" - "github.com/ipfs/go-graphsync" - "github.com/stretchr/testify/require" - blocks "github.com/ipfs/go-block-format" - gsmsg "github.com/ipfs/go-graphsync/message" - "github.com/ipfs/go-graphsync/testutil" "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/libp2p/go-libp2p-core/peer" + "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync" + gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/testutil" ) type fakePeerHandler struct { diff --git a/responsemanager/queryexecutor.go b/responsemanager/queryexecutor.go index 2b859d11..9625ad6e 100644 --- a/responsemanager/queryexecutor.go +++ b/responsemanager/queryexecutor.go @@ -7,6 +7,10 @@ import ( "time" "github.com/ipfs/go-cid" + ipld "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/cidset" "github.com/ipfs/go-graphsync/ipldutil" @@ -14,9 +18,6 @@ import ( "github.com/ipfs/go-graphsync/responsemanager/hooks" "github.com/ipfs/go-graphsync/responsemanager/peerresponsemanager" "github.com/ipfs/go-graphsync/responsemanager/runtraversal" - ipld "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - "github.com/libp2p/go-libp2p-core/peer" ) var errCancelledByCommand = errors.New("response cancelled by responder") diff --git a/responsemanager/responsebuilder/responsebuilder.go b/responsemanager/responsebuilder/responsebuilder.go index 7ca378f6..03f28559 100644 --- a/responsemanager/responsebuilder/responsebuilder.go +++ b/responsemanager/responsebuilder/responsebuilder.go @@ -2,10 +2,11 @@ package responsebuilder import ( blocks "github.com/ipfs/go-block-format" + "github.com/ipld/go-ipld-prime" + "github.com/ipfs/go-graphsync" gsmsg "github.com/ipfs/go-graphsync/message" "github.com/ipfs/go-graphsync/metadata" - "github.com/ipld/go-ipld-prime" ) // ResponseBuilder captures componenst of a response message across multiple diff --git a/responsemanager/responsebuilder/responsebuilder_test.go b/responsemanager/responsebuilder/responsebuilder_test.go index 6c880576..29aa10ce 100644 --- a/responsemanager/responsebuilder/responsebuilder_test.go +++ b/responsemanager/responsebuilder/responsebuilder_test.go @@ -5,13 +5,14 @@ import ( "math/rand" "testing" + "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" gsmsg "github.com/ipfs/go-graphsync/message" "github.com/ipfs/go-graphsync/metadata" "github.com/ipfs/go-graphsync/testutil" - "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - "github.com/stretchr/testify/require" ) func TestMessageBuilding(t *testing.T) { diff --git a/responsemanager/responsemanager.go b/responsemanager/responsemanager.go index 46fd1568..d19bdaf9 100644 --- a/responsemanager/responsemanager.go +++ b/responsemanager/responsemanager.go @@ -6,16 +6,16 @@ import ( "math" "time" - "github.com/ipfs/go-graphsync/responsemanager/hooks" + logging "github.com/ipfs/go-log" + "github.com/ipfs/go-peertaskqueue/peertask" + ipld "github.com/ipld/go-ipld-prime" + "github.com/libp2p/go-libp2p-core/peer" "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/ipldutil" gsmsg "github.com/ipfs/go-graphsync/message" + "github.com/ipfs/go-graphsync/responsemanager/hooks" "github.com/ipfs/go-graphsync/responsemanager/peerresponsemanager" - logging "github.com/ipfs/go-log" - "github.com/ipfs/go-peertaskqueue/peertask" - ipld "github.com/ipld/go-ipld-prime" - "github.com/libp2p/go-libp2p-core/peer" ) var log = logging.Logger("graphsync") diff --git a/responsemanager/responsemanager_test.go b/responsemanager/responsemanager_test.go index 393d3dc6..d9e89d3c 100644 --- a/responsemanager/responsemanager_test.go +++ b/responsemanager/responsemanager_test.go @@ -9,6 +9,13 @@ import ( "time" "github.com/ipfs/go-cid" + "github.com/ipfs/go-peertaskqueue/peertask" + ipld "github.com/ipld/go-ipld-prime" + cidlink "github.com/ipld/go-ipld-prime/linking/cid" + basicnode "github.com/ipld/go-ipld-prime/node/basic" + "github.com/libp2p/go-libp2p-core/peer" + "github.com/stretchr/testify/require" + "github.com/ipfs/go-graphsync" "github.com/ipfs/go-graphsync/cidset" gsmsg "github.com/ipfs/go-graphsync/message" @@ -17,12 +24,6 @@ import ( "github.com/ipfs/go-graphsync/responsemanager/persistenceoptions" "github.com/ipfs/go-graphsync/selectorvalidator" "github.com/ipfs/go-graphsync/testutil" - "github.com/ipfs/go-peertaskqueue/peertask" - ipld "github.com/ipld/go-ipld-prime" - cidlink "github.com/ipld/go-ipld-prime/linking/cid" - basicnode "github.com/ipld/go-ipld-prime/node/basic" - "github.com/libp2p/go-libp2p-core/peer" - "github.com/stretchr/testify/require" ) type fakeQueryQueue struct { diff --git a/responsemanager/runtraversal/runtraversal.go b/responsemanager/runtraversal/runtraversal.go index 5b81ecbc..45bc69c8 100644 --- a/responsemanager/runtraversal/runtraversal.go +++ b/responsemanager/runtraversal/runtraversal.go @@ -4,9 +4,10 @@ import ( "bytes" "io" - "github.com/ipfs/go-graphsync/ipldutil" ipld "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/traversal" + + "github.com/ipfs/go-graphsync/ipldutil" ) // ResponseSender sends responses over the network diff --git a/responsemanager/runtraversal/runtraversal_test.go b/responsemanager/runtraversal/runtraversal_test.go index 8ce42f46..35bc1436 100644 --- a/responsemanager/runtraversal/runtraversal_test.go +++ b/responsemanager/runtraversal/runtraversal_test.go @@ -7,12 +7,12 @@ import ( "io" "testing" - "github.com/ipfs/go-graphsync/testutil" - "github.com/stretchr/testify/require" - ipld "github.com/ipld/go-ipld-prime" cidlink "github.com/ipld/go-ipld-prime/linking/cid" "github.com/ipld/go-ipld-prime/traversal" + "github.com/stretchr/testify/require" + + "github.com/ipfs/go-graphsync/testutil" ) type fakeResponseKey struct { diff --git a/scripts/fiximports b/scripts/fiximports new file mode 100755 index 00000000..0a1edbdb --- /dev/null +++ b/scripts/fiximports @@ -0,0 +1,13 @@ +#!/bin/bash + +find . -type f -name \*.go -not -name \*_cbor_gen.go | xargs -I '{}' sed -i.bak -e '/import (/ { + :1 + $!N + s/\n\n/\'$'\n''/ + /)/!b1 +}' '{}' +git clean -fd +find . -type f -name \*.go -not -name \*_cbor_gen.go | xargs -I '{}' goimports -w -local "github.com/ipfs/go-graphsync" '{}' + + + diff --git a/scripts/mkreleaselog b/scripts/mkreleaselog new file mode 100755 index 00000000..894a2424 --- /dev/null +++ b/scripts/mkreleaselog @@ -0,0 +1,245 @@ +#!/bin/zsh + +# Note: This script is a modified version of the mkreleaselog script used by +# the go-ipfs team. +# +# Usage: ./mkreleaselog v0.25.0 v0.26.0 > /tmp/release.log + +set -euo pipefail +export GO111MODULE=on +export GOPATH="$(go env GOPATH)" + +alias jq="jq --unbuffered" + +REPO_SUFFIXES_TO_STRIP=( + "/v2" + "/v3" + "/v4" + "/v5" + "/v6" +) + +AUTHORS=( + # orgs + ipfs/go-graphsync + + # Authors of personal repos used by filecoin-ffi that should be mentioned in the + # release notes. + xlab + hannahhoward +) + +[[ -n "${REPO_FILTER+x}" ]] || REPO_FILTER="github.com/(${$(printf "|%s" "${AUTHORS[@]}"):1})" +echo $REPO_FILTER +[[ -n "${IGNORED_FILES+x}" ]] || IGNORED_FILES='^\(\.gx\|package\.json\|\.travis\.yml\|go.mod\|go\.sum|\.github|\.circleci\)$' + +NL=$'\n' + +msg() { + echo "$*" >&2 +} + +statlog() { + rpath="$GOPATH/src/$1" + for s in $REPO_SUFFIXES_TO_STRIP; do + rpath=${rpath%$s} + done + + start="${2:-}" + end="${3:-HEAD}" + + git -C "$rpath" log --shortstat --no-merges --pretty="tformat:%H%n%aN%n%aE" "$start..$end" | while + read hash + read name + read email + read _ # empty line + read changes + do + changed=0 + insertions=0 + deletions=0 + while read count event; do + if [[ "$event" =~ ^file ]]; then + changed=$count + elif [[ "$event" =~ ^insertion ]]; then + insertions=$count + elif [[ "$event" =~ ^deletion ]]; then + deletions=$count + else + echo "unknown event $event" >&2 + exit 1 + fi + done<<<"${changes//,/$NL}" + + jq -n \ + --arg "hash" "$hash" \ + --arg "name" "$name" \ + --arg "email" "$email" \ + --argjson "changed" "$changed" \ + --argjson "insertions" "$insertions" \ + --argjson "deletions" "$deletions" \ + '{Commit: $hash, Author: $name, Email: $email, Files: $changed, Insertions: $insertions, Deletions: $deletions}' + done +} + +# Returns a stream of deps changed between $1 and $2. +dep_changes() { + { + <"$1" + <"$2" + } | jq -s 'JOIN(INDEX(.[0][]; .Path); .[1][]; .Path; {Path: .[0].Path, Old: (.[1] | del(.Path)), New: (.[0] | del(.Path))}) | select(.New.Version != .Old.Version)' +} + +# resolve_commits resolves a git ref for each version. +resolve_commits() { + jq '. + {Ref: (.Version|capture("^((?.*)\\+incompatible|v.*-(0\\.)?[0-9]{14}-(?[a-f0-9]{12})|(?v.*))$") | .ref1 // .ref2 // .ref3)}' +} + +pr_link() { + local repo="$1" + local prnum="$2" + local ghname="${repo##github.com/}" + printf -- "[%s#%s](https://%s/pull/%s)" "$ghname" "$prnum" "$repo" "$prnum" +} + +# Generate a release log for a range of commits in a single repo. +release_log() { + setopt local_options BASH_REMATCH + + local repo="$1" + local start="$2" + local end="${3:-HEAD}" + local dir="$GOPATH/src/$repo" + + local commit pr + git -C "$dir" log \ + --format='tformat:%H %s' \ + --first-parent \ + "$start..$end" | + while read commit subject; do + # Skip gx-only PRs. + git -C "$dir" diff-tree --no-commit-id --name-only "$commit^" "$commit" | + grep -v "${IGNORED_FILES}" >/dev/null || continue + + if [[ "$subject" =~ '^Merge pull request #([0-9]+) from' ]]; then + local prnum="${BASH_REMATCH[2]}" + local desc="$(git -C "$dir" show --summary --format='tformat:%b' "$commit" | head -1)" + printf -- "- %s (%s)\n" "$desc" "$(pr_link "$repo" "$prnum")" + elif [[ "$subject" =~ '\(#([0-9]+)\)$' ]]; then + local prnum="${BASH_REMATCH[2]}" + printf -- "- %s (%s)\n" "$subject" "$(pr_link "$repo" "$prnum")" + else + printf -- "- %s\n" "$subject" + fi + done +} + +indent() { + sed -e 's/^/ /' +} + +mod_deps() { + go list -json -m all | jq 'select(.Version != null)' +} + +ensure() { + local repo="$1" + for s in $REPO_SUFFIXES_TO_STRIP; do + repo=${repo%$s} + done + + local commit="$2" + + local rpath="$GOPATH/src/$repo" + if [[ ! -d "$rpath" ]]; then + msg "Cloning $repo..." + git clone "http://$repo" "$rpath" >&2 + fi + + if ! git -C "$rpath" rev-parse --verify "$commit" >/dev/null; then + msg "Fetching $repo..." + git -C "$rpath" fetch --all >&2 + fi + + git -C "$rpath" rev-parse --verify "$commit" >/dev/null || return 1 +} + +statsummary() { + jq -s 'group_by(.Author)[] | {Author: .[0].Author, Commits: (. | length), Insertions: (map(.Insertions) | add), Deletions: (map(.Deletions) | add), Files: (map(.Files) | add)}' | + jq '. + {Lines: (.Deletions + .Insertions)}' +} + +recursive_release_log() { + local start="${1:-$(git tag -l | sort -V | grep -v -- '-rc' | grep 'v'| tail -n1)}" + local end="${2:-$(git rev-parse HEAD)}" + local repo_root="$(git rev-parse --show-toplevel)" + local package="$(cd "$repo_root" && go list -m)" + + if ! [[ "${GOPATH}/${package}" != "${repo_root}" ]]; then + echo "This script requires the target package and all dependencies to live in a GOPATH." + return 1 + fi + + ( + local result=0 + local workspace="$(mktemp -d)" + trap "$(printf 'rm -rf "%q"' "$workspace")" INT TERM EXIT + cd "$workspace" + + echo "Computing old deps..." >&2 + git -C "$repo_root" show "$start:go.mod" >go.mod + sed "s/^replace.*//g" go.mod > go.mod.new + mv go.mod.new go.mod + mod_deps | resolve_commits | jq -s > old_deps.json + + echo "Computing new deps..." >&2 + git -C "$repo_root" show "$end:go.mod" >go.mod + sed "s/^replace.*//g" go.mod > go.mod.new + mv go.mod.new go.mod + mod_deps | resolve_commits | jq -s > new_deps.json + + rm -f go.mod go.sum + + printf -- "Generating Changelog for %s %s..%s\n" "$package" "$start" "$end" >&2 + + printf -- "- %s:\n" "$package" + release_log "$package" "$start" "$end" | indent + + statlog "$package" "$start" "$end" > statlog.json + + dep_changes old_deps.json new_deps.json | + jq --arg filter "$REPO_FILTER" 'select(.Path | match($filter))' | + # Compute changelogs + jq -r '"\(.Path) \(.New.Version) \(.New.Ref) \(.Old.Version) \(.Old.Ref // "")"' | + while read repo new new_ref old old_ref; do + for s in $REPO_SUFFIXES_TO_STRIP; do + repo=${repo%$s} + done + + if ! ensure "$repo" "$new_ref"; then + result=1 + local changelog="failed to fetch repo" + else + statlog "$repo" "$old_ref" "$new_ref" >> statlog.json + local changelog="$(release_log "$repo" "$old_ref" "$new_ref")" + fi + if [[ -n "$changelog" ]]; then + printf -- "- %s (%s -> %s):\n" "$repo" "$old" "$new" + echo "$changelog" | indent + fi + done + + echo + echo "Contributors" + echo + + echo "| Contributor | Commits | Lines ± | Files Changed |" + echo "|-------------|---------|---------|---------------|" + statsummary