Use cases
- The local branch has been pushed to
origin, and a PR needs to be opened tomaster(or a specified base). - Need to write according to the repository template: title, description, self-check items, and optionally for the PR add labels。
Prerequisites
- Installed and logged in GitHub CLI:
gh auth statussuccessfully. - The remote is
github.com/oceanbase/oceanbase-design; the current working directory is the repository root. - If you have just done
rebase/ modified history, you need togit push --force-with-lease origin <branch>before opening or updating the PR.
Title
- UseEnglish、single line, consistent with the main commit or scope of changes.
- Format consistent with historical PRs:
type(scope): short description(e.g.chore(ci): …、fix(design): …、feat(ui): …)。 typecommon:feat、fix、chore、docs、improve, etc.;scopecan be a package name or area (design、ui、root、ci)。
Description (Body)
- Open and follow the repository template:
.github/PULL_REQUEST_TEMPLATE.md。 - In the body,checkthe items corresponding to this change (Modified package, This is a...).
- Fill in the Background and solution、Changelog Chinese-English table; if there is no related issue, you can write
N/A。 - Check Self-Check before Merge the items that have been confirmed or are explicitly not needed.
You can save the body as a temporary file and then pass it to gh(delete the temporary file after use to avoid accidental commits):
gh pr create --repo oceanbase/oceanbase-design --base master --head <你的分支名> \
--title "type(scope): English title here" \
--body-file path/to/body.md
View existing PRs only:
gh pr list --head <你的分支名> --base master
gh pr view <number> --web
Add labels (optional)
After merging or after creation, CI may pass PR Labeler(.github/labeler.yml, the workflow is pull_request_target) according tochanged pathsautomatically add labels,both PRs from branches in the same repository and from forks; if you need tomanuallyadd existing repository labels:
gh pr edit <PR_NUMBER> --repo oceanbase/oceanbase-design \
--add-label "chore" \
--add-label "workflow"
Note: label names must exactly match the repository's existing Labels ; if you do not have permission to create new labels, only add existing ones.
Optional suggested labels (choose by change type, not required)
| Change area | Reference labels |
|---|---|
Root directory / CI / .github |
chore, workflow, CI |
| Documentation only / changelog | documentation, changelog |
| A subpackage | @oceanbase/design, @oceanbase/ui , etc. |
Squash with the previous commit and push
If you need tosquashmultiple commits into one before opening a PR or updating the same branch:
git reset --soft HEAD~<N> # N 为要合并的提交个数
git commit -m "type(scope): single final message"
git push --force-with-lease origin <branch>
Fallback when gh is unavailable
Open in the browser:https://github.com/oceanbase/oceanbase-design/compare/master...<分支名>?expand=1, and paste the template content into the description box.
Anti-patterns
- In the repository,keep long-term
body.mdtemporary files such as those used only forgh; delete them after use and do not add them to version control.