diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..4b86d71 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Getting Help on IPFS + url: https://ipfs.io/help + about: All information about how and where to get help on IPFS. + - name: IPFS Official Forum + url: https://discuss.ipfs.io + about: Please post general questions, support requests, and discussions here. diff --git a/.github/ISSUE_TEMPLATE/open_an_issue.md b/.github/ISSUE_TEMPLATE/open_an_issue.md new file mode 100644 index 0000000..4fcbd00 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/open_an_issue.md @@ -0,0 +1,19 @@ +--- +name: Open an issue +about: Only for actionable issues relevant to this repository. +title: '' +labels: need/triage +assignees: '' + +--- + diff --git a/.github/config.yml b/.github/config.yml new file mode 100644 index 0000000..ed26646 --- /dev/null +++ b/.github/config.yml @@ -0,0 +1,68 @@ +# Configuration for welcome - https://github.com/behaviorbot/welcome + +# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome +# Comment to be posted to on first time issues +newIssueWelcomeComment: > + Thank you for submitting your first issue to this repository! A maintainer + will be here shortly to triage and review. + + In the meantime, please double-check that you have provided all the + necessary information to make this process easy! Any information that can + help save additional round trips is useful! We currently aim to give + initial feedback within **two business days**. If this does not happen, feel + free to leave a comment. + + Please keep an eye on how this issue will be labeled, as labels give an + overview of priorities, assignments and additional actions requested by the + maintainers: + + - "Priority" labels will show how urgent this is for the team. + - "Status" labels will show if this is ready to be worked on, blocked, or in progress. + - "Need" labels will indicate if additional input or analysis is required. + + Finally, remember to use https://discuss.ipfs.io if you just need general + support. + +# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome +# Comment to be posted to on PRs from first time contributors in your repository +newPRWelcomeComment: > + Thank you for submitting this PR! + + A maintainer will be here shortly to review it. + + We are super grateful, but we are also overloaded! Help us by making sure + that: + + * The context for this PR is clear, with relevant discussion, decisions + and stakeholders linked/mentioned. + + * Your contribution itself is clear (code comments, self-review for the + rest) and in its best form. Follow the [code contribution + guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md#code-contribution-guidelines) + if they apply. + + Getting other community members to do a review would be great help too on + complex PRs (you can ask in the chats/forums). If you are unsure about + something, just leave us a comment. + + Next steps: + + * A maintainer will triage and assign priority to this PR, commenting on + any missing things and potentially assigning a reviewer for high + priority items. + + * The PR gets reviews, discussed and approvals as needed. + + * The PR is merged by maintainers when it has been approved and comments addressed. + + We currently aim to provide initial feedback/triaging within **two business + days**. Please keep an eye on any labelling actions, as these will indicate + priorities and status of your contribution. + + We are very grateful for your contribution! + + +# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge +# Comment to be posted to on pull requests merged by a first time user +# Currently disabled +#firstPRMergeComment: "" diff --git a/.travis.yml b/.travis.yml index 4cfe98c..23775ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,13 @@ os: language: go go: - - 1.11.x + - 1.14.x + - 1.15.x env: global: - GOTFLAGS="-race" matrix: - - BUILD_DEPTYPE=gx - BUILD_DEPTYPE=gomod @@ -24,7 +24,6 @@ script: cache: directories: - - $GOPATH/src/gx - $GOPATH/pkg/mod - $HOME/.cache/go-build diff --git a/README.md b/README.md index 79dd928..3edbd8c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,9 @@ go-path > go-path is a helper package that provides utilities for parsing and using ipfs paths +## Lead Maintainer + +[Steven Allen](https://github.com/Stebalien) ## Table of Contents diff --git a/go.mod b/go.mod index a048a15..b070559 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,7 @@ module github.com/ipfs/go-path +go 1.14 + require ( github.com/ipfs/go-cid v0.0.2 github.com/ipfs/go-ipld-format v0.0.2 diff --git a/resolver/resolver.go b/resolver/resolver.go index 67bb9f6..9f15384 100644 --- a/resolver/resolver.go +++ b/resolver/resolver.go @@ -89,6 +89,10 @@ func (r *Resolver) ResolveToLastNode(ctx context.Context, fpath path.Path) (cid. return cid.Cid{}, nil, err } + if len(rest) == 0 { + return lnk.Cid, nil, nil + } + next, err := lnk.GetNode(ctx, r.DAG) if err != nil { return cid.Cid{}, nil, err diff --git a/resolver/resolver_test.go b/resolver/resolver_test.go index 480ccdf..d3c6913 100644 --- a/resolver/resolver_test.go +++ b/resolver/resolver_test.go @@ -105,3 +105,43 @@ func TestRecurivePathResolution(t *testing.T) { p.String(), rCid.String(), cKey.String())) } } + +func TestResolveToLastNode_NoUnnecessaryFetching(t *testing.T) { + ctx := context.Background() + dagService := dagmock.Mock() + + a := randNode() + b := randNode() + + err := a.AddNodeLink("child", b) + if err != nil { + t.Fatal(err) + } + + err = dagService.Add(ctx, a) + if err != nil { + t.Fatal(err) + } + + aKey := a.Cid() + + segments := []string{aKey.String(), "child"} + p, err := path.FromSegments("/ipfs/", segments...) + if err != nil { + t.Fatal(err) + } + + resolver := resolver.NewBasicResolver(dagService) + resolvedCID, remainingPath, err := resolver.ResolveToLastNode(ctx, p) + if err != nil { + t.Fatal(err) + } + + if len(remainingPath) > 0 { + t.Fatal("cannot have remaining path") + } + + if !resolvedCID.Equals(b.Cid()) { + t.Fatal("resolved to the wrong CID") + } +}