Reputation: 4549
I am using hub
to send a pull request from the command line like so:
hub pull-request -b upstream:master -h me:feature
When I do this, hub
automatically opens up my terminal text editor and displays the pull request message so that I can edit it. However, 9.99 times out of 10 I am completely content with the message that hub
chooses as the default, so I would rather just have hub
use the default message without opening up a text editor. Is there any way to do this?
I know I could use hub pull-request -m "message" ...
, to avoid using an editor, but that would actually be more work because I would need to retype the message. None of the other options on the hub
man
page seem to do this either.
Upvotes: 1
Views: 233
Reputation: 4549
This is not possible (and it will likely not be possible in the future for reasons outlined in hub issue #722), but I created a workaround in case anyone else wants this feature in hub
:
Create an empty shell script called something like no-edit.sh
:
echo '#!/bin/bash' > no-edit.sh
chmod +x no-edit.sh
Note: You can edit this script to output the message with cat "$1"
if you want.
Note 2: Alternatively you could just use /usr/bin/true
as recommended by mislav on hub
github issue #722.
Create the following shell script and call it whatever you want (I went with hub-no-edit.sh
):
#!/bin/bash
OLD_GIT_EDITOR=$GIT_EDITOR
export GIT_EDITOR=/path/to/no-edit.sh
hub $@
export GIT_EDITOR=$OLD_GIT_EDITOR
Now just put the second script on your path and you can execute a pull-request
without editing the message:
hub-no-edit.sh pull-request -b base:master -h me:feature
Upvotes: 1
Reputation: 1326784
If you check how commands/pull_request.go#pullRequest()
is implemented, it doesn't seem possible to avoid the editor.
This shouldn't be very difficult to propose a patch adding a new option to this command, which would avoid the lines:
message, err := pullRequestChangesMessage(baseTracking, headTracking, fullBase, fullHead)
utils.Check(err)
editor, err = github.NewEditor("PULLREQ", "pull request", message)
utils.Check(err)
title, body, err = editor.EditTitleAndBody()
utils.Check(err)
The goal would be to directly infer title
and body
from the message
.
Upvotes: 1