node-gh / gh

(DEPRECATED) GitHub CLI made with NodeJS. Use the official https://cli.github.com/ instead.
http://nodegh.io
Other
1.71k stars 217 forks source link

Comment on a submitted pull request #528

Closed brandizzi closed 5 years ago

brandizzi commented 6 years ago

It would be nice to gh to be able to comment on a pull request it just submitted. Something like this:

gh pr -s someuser --comment 'Some comment'

This would be useful, for example, to communicate with CI:

gh pr -s someuser --comment 'ci:test'

Or to mention users:

gh pr -s someser --comment 'cc @​anotheruser'
protoEvangelion commented 6 years ago

@brandizzi Well there are two ways you can accomplish that:

  1. If you are in the process of submitting the PR you can do:
gh pr -s someuser -D "Your comment"

Description is technically a comment.

  1. If you have already submitted the PR, you can do:
gh pr yourPrNumber -c "Your comment"

Does that achieve what you are trying to do?

brandizzi commented 6 years ago

Hello @protoEvangelion!

Well, we already use these alternatives. Yet, we find them less convenient than possible, for two reasons:

  1. Our CI tool does not read the description, only the other comments.
  2. Also, I would rather make a generic description of the pull, and add some other content (such as mentions) in a comment. (There are alternatives for that, sure. I'm even using your second workaround, or sometimes the description. But that'd be nice :) )

If I send a PR for that, would that get merged?

protoEvangelion commented 6 years ago

If I understand you correctly, you are trying to add a comment on PR submit correct?

If that is what you are trying to do, please send a PR and I would be happy to work with you on it to get it merged :)

protoEvangelion commented 5 years ago

After thinking this through again, I realized you can actually use a hook to add as many comments as you want after the PR has been submitted.

In your ~/.gh.json file you can adjust the hook to run whatever cmd you want:

        "pull-request": {
            "submit": {
                "before": [],
                "after": [
                    "{{#if options.number}}gh pr {{options.number}} --user {{options.user}} --repo {{options.repo}} --comment 'Pull request submitted to {{submittedLink}}.{{#if options.changes}} [See changes here.]({{compareLink}}){{/if}}'{{/if}}",
                    "gh pr --browser {{options.browser}} --user {{options.submit}} --repo {{options.repo}} --number {{options.submittedPull}}",
                    "{{#if options.number}}gh pr --user {{options.user}} --repo {{options.repo}} {{options.number}} --close{{/if}}"
                ]
            }
        },