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

How to create a pull request body with hub pull-request #909

Closed
mnquintana opened this issue May 27, 2015 · 15 comments
Labels

Comments

@mnquintana
Copy link

@mnquintana mnquintana commented May 27, 2015

It would be great to add some help text as to how to create a pull request title and body with hub pull-request, as currently nothing is documented. I got this to work with:

echo -e "Pull request title goes here\n\nHere's the pull request body" | hub pull-request -F -

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented May 27, 2015

From hub's man page:

Without <MESSAGE> or <FILE>, a text editor will open in which title and body of the pull request can be entered in the same manner as git commit message. Pull request message can also be passed via stdin with -F -.

So, it says that title and body are entered in the same manner as git commit message, meaning they are separated by a blank line. So you don't have to use echo -e. Simply don't pass any options, and a text editor will open for you.

@mnquintana

This comment has been minimized.

Copy link
Author

@mnquintana mnquintana commented May 27, 2015

@mislav Ah sorry, I forgot to add – I was using hub in a script, so I didn't want it to be interactive.

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented May 27, 2015

Then your approach seems solid. What would you like to see added to the documentation?

@mnquintana

This comment has been minimized.

Copy link
Author

@mnquintana mnquintana commented May 27, 2015

If the approach I used is the recommended way to create a PR title and body inline, then I think it should be given as an example of how to create a PR title and body in the command line. Although it would be nice if the string used for -m were also escaped, so then it could just be: hub pull-request -m "Title goes here\n\nBody goes here"

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented May 27, 2015

We take the string argument to -m literally, and in bash the string "\n" doesn't actually represent a newline by itself. So we can't really support the syntax -m "Title goes here\n\nBody goes here". You could, however, write something like

`-m "$(printf "Title goes here\n\nBody goes here")"`

but command-line arguments aren't really well-suited for passing multiline strings around. Standard input is much better for that, and is what you successfully used.

I guess we could provide some examples. I'll think about it.

@mislav mislav added the docs label May 27, 2015
@webappcreations

This comment has been minimized.

Copy link

@webappcreations webappcreations commented Sep 9, 2016

I do prefer to use a file then instead... but also it would be nice to be able to tell hub which editor to use...

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented Sep 9, 2016

@webappcreations hub will use the same editor that is configured to edit git commit messages:

git config --global core.editor vim

Substitute vim for the editor of your choice. If core.editor isn't set, hub will also do what git does in this case, and inherit editor configuration from EDITOR or GIT_EDITOR environment variables.

@webappcreations

This comment has been minimized.

Copy link

@webappcreations webappcreations commented Sep 10, 2016

thanks that's perfect!

@MurielleB

This comment has been minimized.

Copy link

@MurielleB MurielleB commented Nov 26, 2016

It seems like the -F - option is no longer available, so how do we go about setting a description to our pull request?

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented Nov 27, 2016

@MurielleB The -F - option is absolutely still available, and I have no intent to change it. Which version are you using, and can you upgrade and try again?

@blackjid

This comment has been minimized.

Copy link
Contributor

@blackjid blackjid commented Apr 10, 2018

It would be nice that the pull-request command supports multiple -m flags, just as git commit does.

Each string passed to the -m flag is added to the message separated by a new line. This way the first one is the MESSAGE and all the other ones are the BODY.

hub pull-request -m "My message" -m "Body of the pull-request"

@joel1di1

This comment has been minimized.

Copy link

@joel1di1 joel1di1 commented Jan 24, 2019

hub pull-request -m "My message" -m "Body of the pull-request"

is not working for me, it takes only the last argument.

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented Jan 25, 2019

@joel1di1 You should upgrade to the latest version of hub.

@sinisterstuf

This comment has been minimized.

Copy link
Contributor

@sinisterstuf sinisterstuf commented Oct 31, 2019

This issue seems related to #2281 and unless we want to keep this as an ideation thread, it can probably be considered closed by 4813e85.

@mislav

This comment has been minimized.

Copy link
Member

@mislav mislav commented Oct 31, 2019

Thanks @sinisterstuf

@mislav mislav closed this Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.