gh-stack icon indicating copy to clipboard operation
gh-stack copied to clipboard

Allow editing commit messages when merging a stack

Open amos-ddir opened this issue 2 months ago • 3 comments

Generally loving all the new stack features, thank you! To make it more useful, it would be great if when merging a stack of PRs from the website if we were prompted to choose a commit message like we are if merging one PR at a time.

For further details, we require squash merges and I have a coworker who performs a ton of tiny commits per branch in the stack. The default commit message for the squash merges includes a separate line per commit + blank lines around each; this ends up as a LOT of vertical space in the standard git log output that is really unhelpful.

amos-ddir avatar Sep 03 '26 19:09 amos-ddir

Second this! This is the one big blocker for the new stack feature. I end up having agents merge the PRs sequentially instead of gh merge stack because I end up with enormous commit messages otherwise. It'd be great to have a way to specify the squash commit message for each PR in the stack up front

TedYav avatar Oct 08 '26 21:10 TedYav

Yep, this is the sole reason I don't use the stack feature right now.

steviec avatar Oct 19 '26 12:10 steviec

Same need here. We squash-merge, and the default body with one line per commit is not what we want in the history.

In case it helps others, the merge API used by gh stack merge already accepts a message. PUT /repos/{owner}/{repo}/pulls/{n}/merge-async takes commit_title and commit_message (https://docs.github.com/en/rest/pulls/pulls#merge-a-pull-request-asynchronously), but gh stack merge sends only merge_method and merge_action.

So what I did for a 4-PR stack was one call per PR, bottom first:

gh api --method PUT repos/OWNER/REPO/pulls/101/merge-async --input body.json
gh api repos/OWNER/REPO/pulls/101/merge-async/<uuid>   # until "merged"
{
  "merge_method": "squash",
  "merge_action": "direct_merge",
  "sha": "<current head of the PR>",
  "commit_title": "Title of the change (#101)",
  "commit_message": "Body of the squash commit"
}

What I observed:

  • Calling it on the bottom PR merges only that PR, and GitHub rebases the next PR onto the base branch. Its head SHA changes, so I read it again before the next call.
  • commit_message replaced the default squash body. The docs say "append", but the commit had only my text.
  • commit_title is used as is, so the (#N) suffix has to be added by hand.

This gives up the all-or-nothing stack merge though: if a later call fails, the PRs below it are already merged, and each merge rebases the next PR, which restarts its CI. Having gh stack merge take a title and message per PR (or open an editor for each) would be nice. The API takes only one title and message per call though, so for an atomic merge it may need server-side support too.

cderv avatar Nov 12 '26 17:11 cderv