【文章标题】:Maiao: Gerrit-style code review workflow for GitHub, GitLab, Gitea, others 【文章标题】:Maiao:适用于 GitHub、GitLab、Gitea 等平台的 Gerrit 风格代码审查工作流
【文章正文】: 【文章正文】:
Note: This is a community fork of adevinta/maiao. The original maintainers are no longer at Adevinta and the upstream repository is no longer actively maintained. This fork continues development under runetes/maiao. 注意:这是 adevinta/maiao 的社区分支。原维护者已不再就职于 Adevinta,上游仓库也不再积极维护。此分支将在 runetes/maiao 下继续开发。
Gerrit-style code review workflow for GitHub, GitLab, Gitea, Forgejo, Bitbucket Cloud, and Cursor Origin 适用于 GitHub、GitLab、Gitea、Forgejo、Bitbucket Cloud 和 Cursor Origin 的 Gerrit 风格代码审查工作流
Maiao brings the power of stacked pull requests (or merge requests) to your git hosting provider, enabling you to break large features into small, reviewable commits where each commit becomes its own PR/MR. Maiao 将堆叠式拉取请求(或合并请求)的强大功能引入您的 Git 托管平台,使您能够将大型功能拆分为小型、易于审查的提交,其中每个提交都会生成独立的 PR/MR。
Maiao provides the git review command that:
Maiao 提供 git review 命令,该命令可以:
-
Creates one PR/MR per commit in your branch
-
为分支中的每个提交创建一个 PR/MR
-
Stacks PRs/MRs automatically with proper parent-child dependencies
-
自动堆叠 PR/MR,并建立正确的父子依赖关系
-
Registers native stacks when available (GitHub Stacks, GitLab auto-detected stacks)
-
在支持时注册原生堆叠(GitHub Stacks、GitLab 自动检测的堆叠)
-
Manages fixups elegantly using git commit —fixup
-
使用
git commit --fixup优雅地管理修正提交 -
Tracks commits via Change-IDs (using the Gerrit commit-msg hook)
-
通过 Change-ID 跟踪提交(使用 Gerrit 的 commit-msg 钩子)
-
Auto-rebases your stack when PRs/MRs get merged
-
在 PR/MR 合并时自动对堆叠进行变基
-
Auto-detects your provider from the remote URL
-
根据远程 URL 自动检测您的代码托管平台
| Provider | PR/MR type | WIP/Draft | Native stacks | | 平台 | PR/MR 类型 | WIP/草稿 | 原生堆叠 |
| --- | --- | --- | --- |
|---|
| GitHub | Pull Request | API field | Yes (explicit registration) | | GitHub | Pull Request | API 字段 | 是(显式注册) |
| GitLab | Merge Request | Draft: title prefix | Yes (auto-detected from target branch, up to 20 MRs) | | GitLab | Merge Request | Draft: 标题前缀 | 是(从目标分支自动检测,最多 20 个 MR) |
| Gitea | Pull Request | WIP: title prefix | No | | Gitea | Pull Request | WIP: 标题前缀 | 否 |
| Forgejo/Codeberg | Pull Request | WIP: title prefix | No | | Forgejo/Codeberg | Pull Request | WIP: 标题前缀 | 否 |
| Bitbucket Cloud | Pull Request | Not supported | No | | Bitbucket Cloud | Pull Request | 不支持 | 否 |
| Cursor Origin (beta) | Pull Request | API field | Yes ( parentPullNumber ) |
| Cursor Origin(测试版) | Pull Request | API 字段 | 是(parentPullNumber) |
Maiao auto-detects the provider from your remote URL for known hosts (github.com, gitlab.com, codeberg.org, bitbucket.org, origin.cursor.com). For self-hosted instances, it prompts on first use and saves the choice to git config maiao.provider.
对于已知主机(github.com、gitlab.com、codeberg.org、bitbucket.org、origin.cursor.com),Maiao 会根据您的远程 URL 自动检测平台。对于自托管实例,它会在首次使用时进行提示,并将选择保存到 git config maiao.provider 中。
Make multiple commits
进行多次提交
git commit -m “Add user authentication” git commit -m “Add user authentication”
git commit -m “Add authorization middleware” git commit -m “Add authorization middleware”
git commit -m “Add admin endpoints” git commit -m “Add admin endpoints”
Create stacked PRs/MRs for all commits
为所有提交创建堆叠式 PR/MR
git review git review
Result: Three PRs/MRs created and stacked: 结果:创建并堆叠了三个 PR/MR:
-
PR #1: Add user authentication →main
-
PR #1:添加用户认证 → main
-
PR #2: Add authorization middleware → PR #1
-
PR #2:添加授权中间件 → PR #1
-
PR #3: Add admin endpoints → PR #2
-
PR #3:添加管理员端点 → PR #2
-
Granular Reviews: Each commit reviewed independently for faster, focused feedback
-
细粒度审查:每个提交独立审查,以获得更快速、更专注的反馈
-
Clear History: One logical change per PR/MR maintains clean git history
-
清晰的历史记录:每个 PR/MR 仅包含一个逻辑变更,保持 Git 历史记录整洁
-
Easy Fixups: Address review feedback with git commit —fixup
-
轻松修正:使用
git commit --fixup <sha>处理审查反馈 -
Automatic Stacking: Tool manages PR/MR dependencies automatically
-
自动堆叠:工具自动管理 PR/MR 依赖关系
-
Native Stacks: Integrates with GitHub Stacks and GitLab’s auto-detected stacks
-
原生堆叠:与 GitHub Stacks 和 GitLab 自动检测的堆叠集成
-
Merge Detection: Stack updates automatically when PRs/MRs merge
-
合并检测:PR/MR 合并时自动更新堆叠
-
Rebase Integration: Handles upstream changes gracefully
-
变基集成:优雅处理上游变更
-
Multi-Provider: Works across GitHub, GitLab, Gitea, Forgejo, Bitbucket Cloud, and Cursor Origin
-
多平台支持:适用于 GitHub、GitLab、Gitea、Forgejo、Bitbucket Cloud 和 Cursor Origin
Maiao treats GitHub native stacks as a progressive enhancement. When two or more PRs are pushed, Maiao probes the Stacks API (cached for 24 hours) and registers the PRs as a stack if supported. On older GitHub Enterprise instances the feature is silently skipped — branch-based stacking still works as before. Maiao 将 GitHub 原生堆叠视为一种渐进式增强功能。当推送两个或更多 PR 时,Maiao 会探测 Stacks API(缓存 24 小时),并在支持的情况下将这些 PR 注册为堆叠。在较旧的 GitHub Enterprise 实例上,该功能会被静默跳过——基于分支的堆叠仍像以前一样工作。
Control via git config (default: auto)
通过 git config 控制(默认:auto)
git config maiao.useNativeStack auto # use when available, skip otherwise git config maiao.useNativeStack auto # 可用时使用,否则跳过
git config maiao.useNativeStack true # always register; warn if unavailable git config maiao.useNativeStack true # 始终注册;不可用时发出警告
git config maiao.useNativeStack false # disable entirely git config maiao.useNativeStack false # 完全禁用
-
Getting Started - Installation and workflow guide
-
快速入门 - 安装和工作流指南
-
How Does It Work - Technical details and architecture
-
工作原理 - 技术细节和架构
-
Pricing - Free and open source
-
定价 - 免费且开源
Maiao implements the stacked diffs methodology. Learn more: Maiao 实现了堆叠式差异(stacked diffs)方法论。了解更多:
-
Stacked Diffs Versus Pull Requests - Jackson Gabbard’s foundational article on the philosophy
-
堆叠式差异与拉取请求 - Jackson Gabbard 关于该理念的基础文章
-
Graphite’s Guide to Stacked Diffs - Comprehensive guide to the workflow and best practices
-
Graphite 的堆叠式差异指南 - 关于工作流和最佳实践的全面指南
-
The Pragmatic Engineer: Stacked Diffs - Industry analysis and adoption patterns (paywalled)
-
The Pragmatic Engineer:堆叠式差异 - 行业分析与采用模式(付费墙)
As Maiao encourages users to create smaller and nicer commits in their pull requests, it has been given the name of a tiny island: 由于 Maiao 鼓励用户在拉取请求中创建更小、更精美的提交,因此它被赋予了一个小岛的名字:
Contributions are welcome! See CONTRIBUTING.md for details. 欢迎贡献!详情请见 CONTRIBUTING.md。
MIT License - see DISCLAIMER.md for details. MIT 许可证 - 详情请见 DISCLAIMER.md。