Google open-sources Copybara, its internal tool for syncing code across repos
Copybara is a Google-built utility for transforming and relocating source code between repositories, now available as an open-source project. Its core use case is keeping code synchronized across separate repos—most commonly a private, confidential repository mirrored to a public one, with changes flowing in either direction. Every setup designates one repository as the authoritative source of truth, but contributions and releases can originate from any repo, and incoming changes from non-authoritative repos get transformed and merged back, with conflicts handled like any stale change.
The tool’s defining trait is that it is effectively stateless: rather than tracking sync progress locally, it embeds state as a label in the destination’s commit messages. That design lets multiple people or an automated service run the same configuration and reliably produce identical results. Workflows are defined in a Starlark-based config file (copy.bara.sky) that specifies origin, destination, file globs, and transformations such as path rewrites and moves. Git is the only fully supported backend today, with experimental Mercurial read support and an extensible architecture for adding custom origins and destinations.
Copybara can be consumed via weekly pre-built snapshot binaries—released automatically with no correctness or compatibility guarantees—or compiled from source with JDK 11 and Bazel. It also integrates directly into Bazel workspaces and ships an experimental Docker image configurable through environment variables. For teams juggling internal and public codebases, it formalizes a syncing pattern that many organizations otherwise cobble together with brittle scripts.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.