Skip to content

github_merge_pr: add optional subject/body params (gh pr merge --subject/--body) #44

Closed

Description

@mabry1985

Problem

github_merge_pr (write_tools.py, ~L287–330) builds gh pr merge <n> --repo <r> --<method> [--delete-branch] and offers no way to set the merge commit's subject or body. If the PR has a single commit, GitHub's squash uses that commit's subject, not the PR title. So correcting the PR title before merging doesn't stop a bad subject from landing on main, and there's no way to fix it inside the tool.

Evidence: design-system-plugin#48

  • The PR title was corrected to chore: release v0.16.0 before merge.
  • The single-commit squash still landed on main as feat: chore: release v0.16.0 (#48) (main 4a779cb).
  • The release workflow keys on a chore: release v… subject, so release run 39870343120 was skipped.
  • We recovered by hand with workflow_dispatch (run 39870464197).

The bad feat: prefix comes from projectBoard-plugin#566 / #567, which add a conventional prefix to a title that already has one. Fixing that removes this particular cause. This issue is about the tool: it is still the only in-tool way to correct a bad squash subject before it reaches main, whatever the cause.

Proposed direction

  • Add optional subject: str = "" and body: str = "" params to github_merge_pr.
  • When non-empty, append --subject <subject> / --body <body> to the gh pr merge args. These are gh's existing flags; --body-file isn't needed.
  • Allow them for squash and merge. For rebase, refuse with a clear error, since gh/GitHub ignore a subject on rebase merges and the call would otherwise appear to succeed.
  • Include them in the dry_run preview, e.g. … via squash with subject "chore: release v0.16.0 (#48)", so the operator can confirm the exact subject before confirm=true.
  • Optionally add them to the pr.merged event payload.
  • Update the docstring to say that a single-commit squash uses the commit subject, not the PR title, unless subject is set.

Acceptance

  • github_merge_pr(number=N, method="squash", subject="chore: release vX.Y.Z (#N)", confirm=True) runs gh pr merge N --repo R --squash --subject "chore: release vX.Y.Z (#N)".
  • body maps to --body in the same way. Empty values add no flags, so current behaviour is unchanged.
  • method="rebase" with a non-empty subject or body returns an Error: and does not run gh.
  • The dry-run output shows the subject/body when set.
  • Unit tests cover the arg construction for all of the above.

Refs: projectBoard-plugin#566, projectBoard-plugin#567, design-system-plugin#48

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions