How do I merge a PR?

Table of Contents

This is the last step in the PR Manager lifecycle. Only run it after the user has explicitly confirmed CI is green and all review threads are resolved.

Question

How do I merge a green, approved PR and delete its feature branch?

Answer

  1. Close the bookkeeping first if this PR delivers its task: run compass task done <slug>, write the * Result, and commit on the PR branch — the close-out rides the PR. Merge never touches task state; a task that is still STARTED only draws a warning (tasks may legitimately span several PRs).
  2. Merge — the guard rails are built in: the command refuses while review threads are unresolved or CI is not green, merges (always a merge commit — never squash/rebase), retries GitHub's transient base-branch-modified race, and deletes the remote branch (worktree-safe):

    ./compass.sh pr merge               # current branch's PR
    ./compass.sh pr merge 123           # explicit PR number
    ./compass.sh pr merge --force       # override the guards, stating what was bypassed
    
  3. If the task was left open on purpose, close it on the PR that really finishes it — never with a bookkeeping-only PR.
  4. Sync local main:

    git checkout main
    git pull --ff-only origin main
    

Conventions

  • Wait for explicit user confirmation before merging. gh pr checks can be green for transient reasons; the user holds the authority to merge.
  • Never force-push to main — the project's branch protection rejects it anyway.

Script

compass pr merge (projects/ores.compass/src/compass_pr.py) wrapping gh pr merge --merge (adds --admin when --force is given), deleting the remote branch directly afterwards.

Tested by

Manual.

See also

Emacs 29.1 (Org mode 9.6.6)