Skip to content

PR merge should allow to choose how to format the commit message #1621

Closed

Description

@giacomoalbe

Describe the feature or problem you’d like to solve

gh pr merge is GREAT, it speeds up my workflow a lot, but I find it very annoying that the commit message of the squashed merge action is the last HEAD commit instead of being the PR name/title.

On the website I can change the PR commit message when I'm about to merge it, but using the CLI it's not possible.

Proposed solution

Proposed solution would be to have a preview of the commit message directly inside the CLI, with the ability to choose how to format the commit.

I propose to have 3 different options:

  • PR name (the title which is displayed on the website)
  • Last commit (the current behaviour)
  • Custom message

I don't know if this is something which is to be configured directly in Github settings, but this will greatly benefit the workflow, since I could have in the repo history a way more useful message than the last commit on the HEAD branch (which might be, as usually happens to me, "rebasing master" or "fix linting" or something similar, whereas the message should have been "Add validation logic to Resource (#7)")

Additional context

I would be more than happy to contribute to this feature myself, I'd simply need some guidance since I'm not an expert in either Github GraphQL API or Golang.

Activity

  1. added
    enhancement
    on Sep 4, 2020
  2. added
    help wanted
    on Sep 4, 2020
  3. mislav commented on Sep 4, 2020

    @mislav
    Contributor

    Yikes, that default message won't work at all. Thanks for reporting!

    Ideally, the default commit subject should be <TITLE> (#<PRNUMBER>) to match the web UI's default behavior. In the first iteration, we don't have to provide facilities for editing the commit message, but we can consider that for the future.

    You can try adding a CommitHeadline field here:

    cli/api/queries_pr.go

    Lines 985 to 988 in 0083607

    "input": githubv4.MergePullRequestInput{
    PullRequestID: pr.ID,
    MergeMethod: &mergeMethod,
    },

    Something like:

    CommitHeadline: fmt.Sprintf("%s (#%d)", pr.Title, pr.Number)
  4. achimnol commented on Sep 18, 2020

    @achimnol

    Bump #1023 again here.

  5. mislav commented on Sep 18, 2020

    @mislav
    Contributor

    @achimnol is right; now that the default squash message has been fixed (thanks, @giacomoalbe), the rest of the feature described here is a duplicate of the conversation in #1023. 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions