Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commands/refs: use new cmds #5679

Merged
merged 4 commits into from Nov 7, 2018
Merged

Conversation

overbool
Copy link
Contributor

@overbool overbool commented Oct 27, 2018

Refer: #5664

License: MIT
Signed-off-by: Overbool overbool.xu@gmail.com

@overbool overbool requested a review from Kubuxu as a code owner October 27, 2018 12:56
core/commands/refs.go Outdated Show resolved Hide resolved
Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found another place where we should likely avoid using a channel but otherwise LGTM.

if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
return err
}

out := make(chan interface{})
Copy link
Contributor

@kevina kevina Oct 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should likely drop this channel and go routine and use res.Emit directly for each value.

@Stebalien Stebalien mentioned this pull request Oct 31, 2018
73 tasks
Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to an Oddity with how parsing arguments from Stdin works when ever you have a command that can accept more than one argument from Stdin you must either call req.ParseBodyArgs() before using req.Arguments or iterate over them with req.BodyArgs(), with the former being preferred for now. If you don't only the first argument will be read from Stdin.

You can test this my trying to pass two arguments via the command line to ipfs refs and then try again via Stdin.

@kevina
Copy link
Contributor

kevina commented Nov 7, 2018

@overbool I would also like to get this p.r. in ASAP, let me know if you need any help with this.

License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
@overbool overbool force-pushed the refactor/commands/refs branch 3 times, most recently from b858d06 to bbbaf38 Compare November 7, 2018 08:45
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
License: MIT
Signed-off-by: Overbool <overbool.xu@gmail.com>
@overbool overbool changed the title [WIP] commands/refs: use new cmds commands/refs: use new cmds Nov 7, 2018
@overbool
Copy link
Contributor Author

overbool commented Nov 7, 2018

@kevina I had fixed them, could u help me review again?

Copy link
Contributor

@kevina kevina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One bit but otherwise LGTM.

ctx := req.Context()
n, err := req.InvocContext().GetNode()
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
err := req.ParseBodyArgs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this down...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meh? Honestly, if we're going to do this up-front anyways, we might as well finish parsing the request as early as possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change this later if you'd like.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a strong preference but we should at least try and be consistent about when we do this.

In any case fixing it now is a low priority.

@Stebalien Stebalien merged commit 98f6b2f into ipfs:master Nov 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants