Meta-repo
Repo de manifiesto · Repo de repos
Escrito por Darjus Kazakevic · revisado el
Many repositories, one checkout, and one manifest that can go stale.
A meta-repo is the middle road. Repositories stay separate and separately owned. A manifest file lists which repositories make up a working tree, and at which commit, and a tool clones them all. New developers run one command instead of following a wiki page of fourteen clones. Android's repo tool and ROS's vcstool work this way.
The manifest is both the value and the risk. It is the only place that says what a consistent set looks like, and it goes stale without any error, because nothing breaks when a pin drifts. Also, one checkout is not one commit: a change across two repositories still lands as two merges.
En esencia — Keep separate repositories, and build one working tree from them with a manifest that pins each repository to a commit.
Cuándo recurrir a él
Recurre a él cuando
- New developers must clone a dozen separately owned repositories
- Cross-repo tests need a known, consistent set of revisions
- Repositories must stay separate for ownership or access reasons
Reconsidéralo cuando
- Changes often span repositories and must land together
- Repositories that are never built, run or tested together
- Two or three repositories, where a README is enough
Conceptos clave
- Manifest
- A file that lists each repository, its URL and the revision to check out. It is the only definition of a consistent working tree.
- Pinned revision
- A manifest entry that points at a commit hash, not a branch name. Only a pinned manifest can rebuild last month's working tree.
- Bootstrap command
- One command that clones every repository at its pinned revision and sets up the workspace. This is what most teams adopt a meta-repo for.
- Cross-repo test job
- A CI job that checks out the whole manifest and runs tests across repositories. It is how you know a set of pins actually works together.
Reglas de diseño
- Pin commits, and let CI move the pins
- Pin each repository to a commit, not a branch. Run a nightly job that bumps each pin and runs the cross-repo tests, or the pins drift for months and nothing goes red.
- Don't mistake one checkout for one commit
- The manifest coordinates a working tree, not a change. A change across two repositories still lands as two merges, so each side must work with the other's previous version.
- Give the manifest an owner
- Keep the manifest in its own repository with one owning team, and review changes to it like code. An unowned manifest collects entries for repositories nobody builds any more.
Errores habituales
- A manifest that tracks branch names. It looks fine, and it cannot rebuild anything.
- No job moves the pins. Six months later the manifest describes a tree nobody runs.
- Expecting one pull request to change three repositories atomically, as in a monorepo.