mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-08 21:09:23 +08:00
2.6 KiB
2.6 KiB
description
| description |
|---|
| Land a PR (merge with proper workflow) |
Input
- PR: $1 <number|url>
- If missing: use the most recent PR mentioned in the conversation.
- If ambiguous: ask.
Do (end-to-end)
Goal: PR must end 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> --json number,title,author,headRefName,baseRefName,headRepository --jq '{number,title,author:.author.login,head:.headRefName,base:.baseRefName,headRepo:.headRepository.nameWithOwner}' contrib=$(gh pr view <PR> --json author --jq .author.login) head=$(gh pr view <PR> --json headRefName --jq .headRefName) head_repo_url=$(gh pr view <PR> --json headRepository --jq .headRepository.url) -
Fast-forward base:
git checkout maingit pull --ff-only
-
Create temp base branch from main:
git checkout -b temp/landpr-<ts-or-pr>
-
Check out PR branch locally:
gh pr checkout <PR>
-
Rebase PR branch onto temp base:
git rebase temp/landpr-<ts-or-pr>- Fix conflicts; keep history tidy.
-
Fix + tests + changelog:
- Implement fixes + add/adjust tests
- Update
CHANGELOG.mdand mention#<PR>+@$contrib
-
Decide merge strategy:
- Rebase if we want to preserve commit history
- Squash if we want a single clean commit
- If unclear, ask
-
Full gate (BEFORE commit):
pnpm lint && pnpm build && pnpm test
-
Commit via committer (include # + contributor in commit message):
committer "fix: <summary> (#<PR>) (thanks @$contrib)" CHANGELOG.md <changed files>land_sha=$(git rev-parse HEAD)
-
Push updated PR branch (rebase => usually needs force):
git remote add prhead "$head_repo_url.git" 2>/dev/null || git remote set-url prhead "$head_repo_url.git" git push --force-with-lease prhead HEAD:$head -
Merge PR (must show MERGED on GitHub):
- Rebase:
gh pr merge <PR> --rebase - Squash:
gh pr merge <PR> --squash - Never
gh pr close(closing is wrong)
- Rebase:
-
Sync main:
git checkout maingit pull --ff-only
-
Comment on PR with what we did + SHAs + thanks:
merge_sha=$(gh pr view <PR> --json mergeCommit --jq '.mergeCommit.oid') gh pr comment <PR> --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> --json state --jq .state
-
Delete temp branch:
git branch -D temp/landpr-<ts-or-pr>