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 -
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.
@mislav Ah sorry, I forgot to add – I was using hub
in a script, so I didn't want it to be interactive.
Then your approach seems solid. What would you like to see added to the documentation?
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"
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.
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...
@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.
thanks that's perfect!
It seems like the -F - option is no longer available, so how do we go about setting a description to our pull request?
@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?
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"
hub pull-request -m "My message" -m "Body of the pull-request"
is not working for me, it takes only the last argument.
@joel1di1 You should upgrade to the latest version of hub.
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.
Thanks @sinisterstuf
Most helpful comment
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 likebut 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.