Skip to content

chore: squash-merge commit body from ## Description only - #825

Open
nekomoto911 wants to merge 1 commit into
Galxe:mainfrom
nekomoto911:chore/squash-merge-description-only
Open

chore: squash-merge commit body from ## Description only#825
nekomoto911 wants to merge 1 commit into
Galxe:mainfrom
nekomoto911:chore/squash-merge-description-only

Conversation

@nekomoto911

Copy link
Copy Markdown
Contributor

Description

GitHub squash defaults can only use the whole PR body, not a subsection. Make ## Description the squash-commit body by convention, and add helpers to extract/merge with that section only.

  • document the convention in PULL_REQUEST_TEMPLATE.md
  • scripts/pr-description.sh — print ## Description until the next ##
  • scripts/pr-squash-merge.shgh pr merge --squash with PR title + Description
  • repo setting: squash title=PR_TITLE, message=BLANK (avoid dumping checklists into main)

Usage: scripts/pr-squash-merge.sh <pr> (or paste Description in the UI).

Issue Number: n/a

How Has This Been Tested?

  • scripts/pr-description.sh 824 --repo Galxe/gravity-sdk returns only the Description section

Type of Change

  • Documentation update
  • Other (specify)

Checklist

  • I have performed a self-review of my own code

GitHub cannot natively use only the Description section of a templated
PR body. Document that convention, add extract/merge helpers, and leave
repo squash message default blank so UI merges do not dump the checklist.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8101b81986

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

printf '%s' "$desc"
echo "-----------------"

gh pr merge "$pr" "${repo_args[@]}" --squash --subject "$title" --body "$desc" "${extra[@]}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Pin the PR head before invoking the merge

When this helper is run with the advertised --admin option—or with rules that do not invalidate approval after a push—a contributor can update the PR after the body/title reads on lines 49–50 but before this command executes. gh pr merge then merges the PR's new head while the operator sees metadata fetched from the earlier state, potentially admitting unreviewed code. gh pr merge --help documents --match-head-commit SHA as requiring the PR head to match that SHA; fetch headRefOid with the metadata and pass that option. This can be validated by pausing a mocked second gh pr view, changing the head, and observing that the current invocation contains no expected SHA.

AGENTS.md reference: AGENTS.md:L5-L12

Useful? React with 👍 / 👎.

Comment thread scripts/pr-description.sh
Comment on lines +59 to +60
nxt = re.search(r"(?m)^##\s+\S", rest)
section = rest[: nxt.start()] if nxt else rest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Ignore fenced-code contents when locating the next heading

For a Description containing a fenced Markdown example with a line such as ## Example, this regex treats that line as the next section heading even though Markdown renders it as code. The extractor consequently truncates the commit body—potentially in the middle of an open fence—and drops all subsequent Description text. A minimal body of ## Description, before, an opening fence, ## Example, a closing fence, after, and then the real next H2 reproduces output containing only before and the opening fence; heading detection needs to account for fenced blocks.

AGENTS.md reference: AGENTS.md:L6-L12

Useful? React with 👍 / 👎.

@nekomoto911

Copy link
Copy Markdown
Contributor Author

Clarification on squash defaults vs the helper scripts:

GitHub web UI can only prefill Extended description as the entire PR body (PR_BODY), commit list, or blank — it cannot take ## Description alone. Repo setting is restored to PR_TITLE + PR_BODY so the UI is not empty.

scripts/pr-squash-merge.sh is for CLI merges only (gh pr merge --squash), where we can pass a custom body: it extracts ## Description and uses that. The web Squash button does not run this script.

UI workflow: edit the prefilled body down to Description before confirming.
CLI workflow: scripts/pr-squash-merge.sh <pr>.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant