Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@samcoe
Copy link
Contributor

@samcoe samcoe commented Dec 2, 2020

This PR allows for commenting on issues. It is branched off of @Yuuki77's work in #2008. Thanks @Yuuki77 for getting this work started πŸ™‡ . I left major design decisions/comments inline with the code.

One feature I would like to add in the future is showing the most recent comments in editor mode, to give the user context for their comment. I think having #2462 merged in would make that feature significantly easier to implement which is why I am going to hold off for now. If that gets merged in before this one, then I will take a pass at implementing it.

cc #517

@samcoe samcoe self-assigned this Dec 2, 2020
IO: f.IOStreams,
HttpClient: f.HttpClient,
Config: f.Config,
Edit: func(editorCommand string) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This pattern is necessary for testing purposes and copied from the gist commands.

@samcoe samcoe marked this pull request as ready for review December 2, 2020 20:43
@samcoe samcoe force-pushed the create-comments branch 2 times, most recently from 1a2402d to df399e3 Compare December 3, 2020 18:49
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

This is looking great! Some suggestions on how we could simplify the interactivity around the command and its implementation

Comment on lines 177 to 178
Message: "Where do you want to draft your comment?",
Options: []string{"In line", "Editor", "Web"},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this survey prompt is useful. I'm imagining that, if our users were to write a comment interactively, they would appreciate if we launched a text editor immediately.

Would we consider --editor being implied (and removing it as an explicit flag) if --body and --web were not supplied? And then launching an editor directly without prompting, since the user already gave us an indication that they want to write a comment?

That would mean that we would only interface with the Survey library to show the Submit? step once the editor finishes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like this optimization, it makes this command work similar to git commit. I wonder if we would even want a Submit? prompt in that case. @ampinsk @vilmibm do you have any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think jumping straight into the editor from the prompt would be jarring, especially because it's very unlike the rest of gh to do so. I'd prefer to keep the design of this as is, but if you both feel strongly I'm open to discussing it! Curious if @vilmibm has thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm unsure about this and for that reason do want to ship it like this; i want to see how it feels and if we get feedback on it.

i think we're still establishing best practices around interactive modes and some inconsistency / extra verbosity might help us narrow down those practices.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think jumping straight into the editor from the prompt would be jarring, especially because it's very unlike the rest of gh to do so.

Agreed that it might be jarring. But for a purpose like editing, where there is only one field to collect (as opposed to opening an issue or PR), I think that it could be something that we could get away with. However, if we were to also provide the Web option, then absolutely, the first prompt is in order.

My objection was mostly for providing the In line vs. Editor option, as I don't understand why users would choose the In line option (where neither readline nor terminal escape sequences are supported), over their full-featured editor?

The second thing that I believe can reduce friction is that we skip the additional [e] to launch editor prompt which follows the user's choice of Editor, and jump straight into editing instead:

? Where do you want to draft your comment? Editor
? Body [(e) to launch vim]     <--- does anyone benefit from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I played around with this a bit and decided to keep the input survey but removed the In line option. The main reason was because survey does not use readline and does not handle terminal escape sequences well, this made the overall editing experience poor. If users want to supply the body message in line they will need to use the --body flag.

I agree that the second prompt to open the editor is unnecessary and will see if I can remove it.

@Oshimarr36
Copy link

Experience

@shindere
Copy link

shindere commented Jan 5, 2021 via email

Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

This works and looks great! Good job 🌟

return &Comments{Nodes: comments, TotalCount: len(comments)}, nil
}

func CommentCreate(client *Client, repoHost string, params map[string]string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this method is only to be used in pkg/cmd/issue and pkg/cmd/pr packages, consider placing it in pkg/cmd/issue/shared/http.go instead. I feel like we should shrink down the API package to only have generic API functionality, and specific queries are implemented in individual packages that need them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd like to think about this more so I am going to leave it in place for this PR and then address it when working on commenting for PRs.

Comment on lines +46 to +49
EditSurvey: editSurvey(f.Config, f.IOStreams),
InputTypeSurvey: inputTypeSurvey,
ConfirmSubmitSurvey: confirmSubmitSurvey,
OpenInBrowser: utils.OpenInBrowser,
Copy link
Contributor

Choose a reason for hiding this comment

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

This is cool! πŸ†

@samcoe samcoe requested a review from mislav January 11, 2021 21:57
Copy link
Contributor

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Fantastic. Thank you for the updates! 🌟

@samcoe samcoe merged commit b0ae09e into trunk Jan 12, 2021
@samcoe samcoe deleted the create-comments branch January 12, 2021 19:24
Copy link
Contributor

@just1a-person just1a-person left a comment

Choose a reason for hiding this comment

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

GitHub CLI comment test

@just1a-person
Copy link
Contributor

Wait! I cannot comment normally? I have to review it?

@mislav
Copy link
Contributor

mislav commented Jan 13, 2021

@itsme-alan Please test CLI functionality in a separate repo, and if you find a bug in merged functionality, please open an issue.

Note that this PR only advertises functionality to comment on Issues; to comment on Pull Requests (this is separate from leaving a review comment, which is already possible) some additional changes might be required. πŸ™‡

@samcoe samcoe mentioned this pull request Jan 13, 2021
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.

8 participants