Reputation: 8386
gh pr create
is being integrated into our workflow, currently being used in interactive mode.
Yet, we observe the following behaviour:
develop
HEAD): gh pr create
does not offer a default title.gh pr create
proposes the commit's message as the default PR title.gh pr create
proposes the branch's name as the default PR title.Is there a way to ask the gh
tool to use the branch's name in all situations?
Edit: @bk2204 raises the option of explicitly providing the title from arbitrary subshell computation. It is a good improvment, sadly, it would not be a "default title" anymore, in the sense that the interactive process of gh pr create
would not offer to override this title anymore.
Upvotes: 1
Views: 1503
Reputation: 76774
I'm not 100% certain, but I believe this is the default behavior of the GitHub interface for a PR if you don't specify a title at all. In other words, because you haven't specified a title explicitly, it picked the value it would have picked as if you opened the PR in the web interface.
If you want to always use the branch name as the title, then you can use the -t
option like so:
$ gh pr create -t "$(git rev-parse --abbrev-ref HEAD)"
The part in the command substitution provides the branch name if you are on a branch. You could add additional commands if you want to replace dashes with spaces or such, and you could create a suitable alias if you like.
I will point out that in many environments, the branch name is not an especially good PR title. Sometimes people place their initials or username in the branch, which is probably not relevant for a PR title. I personally am very bad at naming branches and so I will always end up wanting to edit the title. There are various other reasons to adopt a different approach as well.
Upvotes: 3