vermiculus / magithub

**DEPRECATED - please use Forge instead!** -- Magit-based interfaces to GitHub
GNU General Public License v3.0
579 stars 63 forks source link

Use commit message for pull request message #237

Closed aaronjensen closed 6 years ago

aaronjensen commented 6 years ago

Both github and magit-gh-pulls use some combination of commit messages as the default message for a pull request if there is no template.

Specifically, I like github's behavior where, in the case of a single commit PR, the commit's message becomes the PR's title and description.

It'd be great if magithub did something similar. Thanks!

vermiculus commented 6 years ago

I've been wanting to do something like this, too – I've legitimately been copy/pasting the commit title into the PR body when I open one. Very boring 😄

The only hesitation I've had is that I want to insert the full commit log between BASE and HEAD; I've yet to figure out how to do that. I'll prioritize it this weekend.

vermiculus commented 6 years ago

Hey @tarsius – do you know off the top of your head if there's anything in magit that would help me here? Otherwise I think I just have to run a git log command myself (not a big deal; I just don't want to re-do existing work).

tarsius commented 6 years ago

I cannot think of anything that Magit provides. Instead of git log you probably can use git show -q instead.

vermiculus commented 6 years ago

What does -q do? I can't find it in the git-show manpage.

tarsius commented 6 years ago

Maybe it has --quiet instead? If I remember correctly that suppresses the diff.

vermiculus commented 6 years ago

That is, an isearch on -q showed no results. It's not online, either. Sounds like a ticket to git for an undocumented option? 😉

tarsius commented 6 years ago

Or maybe I was wrong. You might want to test it before sending a mail. 😉

vermiculus commented 6 years ago

git show -q definitely does something. It looks like it just shows HEAD.

tarsius commented 6 years ago

What you want is git show -q --format=%b REV (instead of git log --oneline -1 --format=%b REV, which you didn't spell out completely, which is why I omitted the details too).

vermiculus commented 6 years ago

Still looks like git-show only shows one commit.

I had something like git log --format=%H%n%B master..HEAD in mind (where the master would be the BASE branch). I.e., if I'm merging two commits:

deadbeefhash1
commit title

body...

deadbeefhash2
commit title

body...
tarsius commented 6 years ago

Still looks like git-show only shows one commit.

Ah, I thought you wanted that. (Github only ever uses the commit message as template if the pr has only one commit.)

vermiculus commented 6 years ago

Which I think is silly 😄 we can do better.

Unless... do you think it would be better UX to just show a magit-log of changes to be merged in a buffer on the side? (And defaulting in the commit message if it's just one commit?)

aaronjensen commented 6 years ago

FWIW, magit-gh-pulls uses the short message of all commits in the PR. I always delete them. Always. I've never wanted to open a PR w/ a list of my commits. I sometimes leave the first commit as the title in the case where I do a thing that is the main point of the PR, then commit it, then commit some other fix/cleanup/etc.

But usually I just delete them.

The one nice thing with it, however, is that I see an overview of all of my commits which may help me name my PR.

vermiculus commented 6 years ago

But usually I just delete them.

So not in the edit buffer, then. Would you not want it even there's only one commit? (i.e., HEAD~1 = BASE)

The one nice thing with it, however, is that I see an overview of all of my commits which may help me name my PR.

So definitely a plus for showing (magit-log "BASE..HEAD" (magit-log-arguments)).

aaronjensen commented 6 years ago

If it's just one commit, I'd love for its commit message to be the default PR message in the edit buffer.

vermiculus commented 6 years ago

Here's a question: what should we do if there's a PULL_REQUEST_TEMPLATE?

vermiculus commented 6 years ago

My gut instinct is to just append the template to whatever we have.

aaronjensen commented 6 years ago

IMO use it for the body and use the commit message first line for the title? Is that what GH does? I'd probably just do exactly what GH does.

aaronjensen commented 6 years ago

thinking about it more, I like your idea. append the template to the first commit message--that works for me.

vermiculus commented 6 years ago

This is definitely one of those features I'm so glad to have done; it adds way more to the experience than I expected. Thanks for the issue!

aaronjensen commented 6 years ago

Thanks!

aaronjensen commented 6 years ago

I finally got around to testing this and it doesn't appear to work. Is there a var I have to set? I have a PR template in my repo

aaronjensen commented 6 years ago

actually, it did work, I had to pick master instead of HEAD. I'm not sure why HEAD is an option--it doesn't appear to work to create prs against... i would have thought it was the default branch

vermiculus commented 6 years ago

As discussed in #264, HEAD shouldn't be an option. I'm investigating; thanks for the report 👍

humitos commented 6 years ago

@vermiculus looking for this feature I arrived here. Do I have to enable it in some way? I don't know why it's not working in my emacs.

vermiculus commented 6 years ago

It should work out of the box if you're just merging one commit. If you're merging multiple commits, there's no good way to choose a commit message, so we just show the commits you're about to request to merge. The only stuff you'd have to 'turn on' should be listed in magithub-feature-list.