-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add the ability to edit issues #2432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job, looks fantastic, thank you! The test coverage is great 🏆 Left some requests for cosmetic changes mostly.
One thing that rubs me the wrong way (but needn't block your PR right now) is the usage scenario for opening the text editor to edit issue title & body:
hub issue edit 1337 --edit
The fact that one has to write "edit" twice feels awkward to me, but I don't know what's a better solution. In hub release edit
, we open the text editor by default to edit the existing release title & body; one can skip that by passing --message ""
, but this is also awkward.
I'm not sure which would be the better way in the long run. Since this is a new feature, perhaps we could consider another API that's even better than both hub issue edit --edit
and hub release edit -m ""
? However, I won't require code changes from you around this until we reach some consensus.
I addressed the issues you pointed out. Let me know if there is anything else.
Agreed. Maybe a
If you have ideas for the API let me know, I'm happy to tackle them. |
@mislav, any thoughts on the PR and API? |
@jfahrer Sorry, I had to think this over. Off the top of my head, these are parts of an issue that a person might want to edit:
We want to enable the user to be able to programatically edit one or any combination of these fields. We also want to enable the user to interactively edit title & body by opening their text editor, similarly to their experience with Lets look at some hypothetical
Sorry for so many questions. I'm just brainstorming how I envision editing on the command-line to go. I think the reason we didn't support editing so far is because is so much more complex than creating. Anyway, any thoughts that you have are welcome. |
Thanks for taking the time!
An alternative could be using a different keyword than
Since the editor would contain the current title and body I'm not sure it would be that disruptive. There should however be a way to prevent the editor from opening. I saw
It feels a little confusing that the behavior changes based on whether certain flags are passed or not. I feel like my prior comment about changing the keyword is better suited here.
I think the
You are right. I wonder if we should support
This will currently work
I assume you mean interactively? I can't really judge whether this something needed or not. It doesn't seem like a crucial feature tho. |
That's a great idea. Let's go with
I think this could be surprising, so let's not define a default just yet. We can always choose a good default in the future when it becomes clear how people are using
You're right, it's pretty edge-casey so we don't have to worry about that for now.
I also think that this would be the most user-friendly, but you can skip implementing add/remove labels for now, and just support
Yeah, Thank you for your thoughtful suggestions! |
Excellent. I updated the PR. I couldn't find anything that returns the number of flags or a list of flags so that the
Sounds good. Let me add
I'll skip this for now then. |
That might be one approach, but instead I would opt for the more explicit approach of checking whether specific flags were passed (in case there will be other if !args.HasReceived("--edit") && !args.HasReceived("--message") && !args.HasReceived("--labels") && ... {
utils.Check(cmd.UsageError("please specify fields to update"))
} |
You got it |
utils/args_parser.go
Outdated
@@ -183,6 +183,15 @@ func (p *ArgsParser) HasReceived(name string) bool { | |||
return found && len(f.values) > 0 | |||
} | |||
|
|||
func (p *ArgsParser) HasReceivedOneOf(names []string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be too much to open the ArgsParser API up like this. It felt more natural to put this logic here instead of the Issue. Let me know if you want me to move it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too specific for ArgsParser (which I intentionally kept small), so I'd rather that this is inlined in issue.go or encapsulated as a function that takes an ArgsParser instance and a list of flags.
Btw you can have a Go function accept a list of arguments instead of a slice:
func HasReceivedOneOf(names ...string) bool {
}
// usage:
HasReceivedOneOf("foo", "bar")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too specific for ArgsParser (which I intentionally kept small), so I'd rather that this is inlined in issue.go or encapsulated as a function that takes an ArgsParser instance and a list of flags.
Sounds good, I inlined the check in issue.go.
Btw you can have a Go function accept a list of arguments instead of a slice:
Cool, I didn't think of that. Thanks for the tip!
utils/args_parser.go
Outdated
@@ -183,6 +183,15 @@ func (p *ArgsParser) HasReceived(name string) bool { | |||
return found && len(f.values) > 0 | |||
} | |||
|
|||
func (p *ArgsParser) HasReceivedOneOf(names []string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too specific for ArgsParser (which I intentionally kept small), so I'd rather that this is inlined in issue.go or encapsulated as a function that takes an ArgsParser instance and a list of flags.
Btw you can have a Go function accept a list of arguments instead of a slice:
func HasReceivedOneOf(names ...string) bool {
}
// usage:
HasReceivedOneOf("foo", "bar")
This made sense for `issue create`, where a person would want to obtain the URL to the new issue, but it makes less sense for `issue update`, where the user already knows the issue number (which will not change). This makes it so that the successful run has no output, but since I don't know what a better confirmation behavior would be, I think this is fine for now.
A body will typically have CR-LF when it was authored using web UI on Windows.
@jfahrer Pushed some tweaks to your branch, such as supporting updating issue state. Thank you for the amazing work here! ✨ |
Thank you! |
This PR adds the ability to edit existing issues using the same interface as
hub issue create
.There is a little duplication between creating and editing issues that could be removed. I'm not convinced that removing the duplication would increase clarity and readability.