/landpr
Input
- PR:
<pr-number>
Do (end-to-end)
Goal: PR ends in GitHub state MERGED (never CLOSED). Use gh pr merge with --rebase or --squash.
- Repo clean:
git status. - Identify PR meta (author + head branch):
gh pr view <pr-number> --json number,title,author,headRefName,baseRefName --jq '{number,title,author:.author.login,head:.headRefName,base:.baseRefName}'contrib=$(gh pr view <pr-number> --json author --jq .author.login)head=$(gh pr view <pr-number> --json headRefName --jq .headRefName)
- Fast-forward base:
git checkout maingit pull --ff-only
- Create temp base branch from
main:git checkout -b temp/landpr-<pr-number>
- Check out PR branch locally:
gh pr checkout <pr-number>
- Rebase PR branch onto temp base:
git rebase temp/landpr-<pr-number>- fix conflicts; keep history tidy
- Fix + tests + changelog:
- implement fixes + add/adjust tests
- update
CHANGELOG.mdand mention#<pr-number>+@$contrib
- Pick merge strategy (if unclear, ask):
- Rebase: preserve commit history
- Squash: single clean commit
- Full gate (BEFORE commit):
pnpm lint && pnpm build && pnpm test
- Commit via
committer(include#<pr-number>+ contributor in commit message):
committer "fix: <summary> (#<pr-number>) (thanks @$contrib)" CHANGELOG.md <changed files>- capture
land_sha=$(git rev-parse HEAD)
- Push updated PR branch (rebase => usually needs force):
git push --force-with-lease
- Merge PR (must show MERGED on GitHub):
- Rebase:
gh pr merge <pr-number> --rebase - Squash:
gh pr merge <pr-number> --squash - Never
gh pr close
- Sync
main+ push:
git checkout maingit pull --ff-onlygit push
- Comment on PR with what we did + SHAs + thanks:
merge_sha=$(gh pr view <pr-number> --json mergeCommit --jq '.mergeCommit.oid')gh pr comment <pr-number> --body "Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: $land_sha\n- Merge commit: $merge_sha\n\nThanks @$contrib!"
- Verify PR state ==
MERGED:
gh pr view <pr-number> --json state,mergedAt --jq '.state + \" @ \" + .mergedAt'
- Delete temp branch:
git branch -D temp/landpr-<pr-number>