Skip to content
master
Switch branches/tags
Code

Latest commit

Included changes:

  - 8cea7651b8f08c06a5fe9c085bef6899fe084517 Cleanup AbstractActionInputPrefetcher and split RemoteAct...
  - 4eb62cd07393e495ab9ead49b771871d1050ee51 Automated rollback of commit 577cfbc8a2b0841cd67a918febe9...
  - 84f819a8f400d4f3accc2906e41297132c580247 Make ActionStats a private-static inner class of MetricsC...
  - 20269a6b298c0db7dc155ccb1b3e76ddfe717e00 Update SplitCommandLine test helper names
  - 51edf39c1dc4a0c870e29de7747d22e7277eb902 Remove DexArchiveAspect.propagateDownLegacyToolchain.
  - 577cfbc8a2b0841cd67a918febe9e3c5fcb3882e Set --legacy_important_outputs to false by default.
  - 4b87044a429b6c2a144d7c0d6fa7850eb1309592 Wrap rules repository declarations in maybe().
  - eedab27017723d818757d6be6f9f258529223c26 Remove injected metadata before rewriting the `.jdeps` fi...
  - 4879106fabdf4af9395743941987d4297d232296 Move --incompatible_override_toolchain_transitions to the...
  - c0b87c564e83220a81facbcb534b4f81798c2cfd Automatic code cleanup.
  - 35465429064248b9e13dad9a24cc65113729d58e Automated rollback of commit 61fd06d92706d64fbcef64f0f54c...
  - 121a857807b4493ebc38b99a8ce9b15769eb9f7b Fix a bug with the event-based result collection.
  - 06d2aaddf4cbf6ce1cfa16ee9d9a291a57aef244 Disable bazel_module_test with RBE
  - 798bd5e20ba80d5441b0cdb5f50db044ea311e9e Use the helper for declaring the cc toolchain type on rul...
  - 2f03f9c44faac37d5dea5b436866620778e44162 Apply TopLevelStatusEvents to non-Skymeld code path.
  - c8116b166cc09e1607db437ed4395a3153b45629 Explicitly mention that `alias()` ignores `testonly`.
  - f068b31c94eef1ea10477a755d9173b4fadf6485 Make `--incompatible_disallow_legacy_py_provider` a no-op
  - 8b4ca0185bd39aa90024f4572825ad9266b67fe6 Updated p3 description to encourage community contributio...
  - 9f024ae2e37f077a2797872c635d776c2bf28009 Remove unused method from `FileWriteAction`.
  - ab24880012a3e661d4baeba39517d8a48fcf653c Disable workspace(managed_directories).
  - 44fef497a1053084493e304a410553ab29e06fe6 Delete CompletableFuture.
  - ee3637c19c131cf295eaa3fb59ea03f6e9a1f60e Add some missing dependencies to the built-in module baze...
  - a54a1a7e0e3a8faa35fbc0782c8dcf8ce12b86e5 Update native rules to use a common definition for the CC...
  - 1fdf1e1e1c8b09205e527099942cc38636e53457 Update #equals and #hashCode of BuildDriverKey to include...
  - 9b0518d1b20dec80c050704d371a53e0280480f3 More accurate naming for helper methods.
  - fc5bf5459a52d1ea68b3dcd9fa582de118e452d1 Add a helper for declaring the cc toolchain type on rules...
  - 46bb5459f16167c880c1354d52057a9000addec4 Add dependency on rules_license
  - ed7a0565f02b496bc4fc613157111638e8dd997f Remove unused `--default_android_platform` flag.
  - c1009c2ef780b7408c9c9284402eacfaa5407c4c Add helper to centrally define the CC toolchain type requ...
  - 11dda14d3a32755bf6a6b80b124fffc926e6e92c Fix an issue in parse_netrc that it doesn't support TAB.
  - d273cb62f43ef8169415cf60fc96e503ea2ad823 Unify URL/URLs parameter code across http_archive, http_f...
  - e575800149c6dc6bd4589d96d8739f18ccdcb2cf Revert name of implicit dependencies in Java proto librar...
  - 668805aace9bf96f78595fc2a122027a3000ceac Upgrade zlib to 1.2.12
  - 43cb21ac44bbe4a7ab4a589afa71a2c59bf1d79c Manage temporary files inside AbstractActionInputPrefetcher
  - 8179e78ab21de47351c4d530950c92580d29257d Bazel DevSite: Add link to 5.1.1 docs
  - 6e03d0cca37192b27c29891a3b5b11b373cc387d Semiautomated rollback of changelist 176873598.
  - 0937d457be990ed8076681553d7df3b6b18afb9b Refactor ASM version handling
  - b0487dc28eeb2ce3c0485cf0a21a5e69fbb00bc3 Avoid keying libraries from link_multi_arch_static_librar...
  - 61fd06d92706d64fbcef64f0f54cded91c88afff Remove some JDK 8-only logic in DumpPlatformClassPath
  - bbf74d5bc85e2bc9bb1d28b611fd9a15294b78e3 Drop redundant `ErrorProneTimings` shim from `ErrorProneP...
  - 0c9598f2336ba3bd2111863bc531ff5467b9f876 Remove cc_proto_library helper methods from semantics file.
  - f755d88c2fe93bf15dd93be174399c788b35c5bb Set BuildDriverKey as CPU-heavy.
  - cdb77503765eac5936be4b02201fc2c7f259d84c Add WorkerKey to the ResourceSet.
  - 17ed57ac5ad9b52bfc43e52ca40512f7114c58aa cpp: support vendor'ed clang
  - c878c67269fd6c321429c06ae4035472c9e12522 Automatic code cleanup.
  - 03ad0cd1203b7b54ec02ea3f5788d1d673a9d6d6 main: do not declare `environ` on Windows
  - d326889986a0a5fb6409c315f6d5e9f165dde40d Remove stale comment. #cleanup
  - 467f32d8087fed11bd480ec5112bf1228b63053d linux-sandbox: do not treat large user IDs as negative nu...
  - 6bad1a123ced4d0e9b2103e50c61c2d216873fc7 Build desugared library DEX in release mode
  - 054a0261fdcb36d47562faf98a025465ded87133 Fix unwanted retention of StarlarkDefinedAspect-s.
  - ca3211f8b9f6c03e165576ba69a1531e1febea0b Formatting change #cleanup.
  - d46269fe2397b4612a654543ba6fed45c2cdbdea Fix handling Java proto libraries '/' in the name.
  - 4099f0f1233f0326a1f596d5689576455bad9048 Check the providers are there in java_proto_library
  - 510edc2a9200481cbb2da6222acd0b9f4d7d85b3 Fix DependencyResolver to properly handle toolchain depen...
  - 1afd26a86cb6889eedf96289abbe3fa79310470c Add licenses and distribs attribute to java_proto_library
  - 8b9147d98c29783e710b2178a735b59a29b2df49 Optimise short paths in JavaInfo provider.
  - 44d94f793c6abfdf88ef5a8676f813e6bb2ca2c4 Drop source jars in java_common.compile when create_ouput...
  - dbb8b6ed249a54b6321128fa56c18f457728cc98 Optimise path producing empty JavaPluginInfo in JavaPlugi...
  - 24899171a0495fde79cc42e12cbc1b195d29fcf3 Add implementation for key translations for BuildInfo.
  - 20b5a539b6ae5bf9bdf3d6edc4eaf1ea00b15495 Switch to the NoFinalizer variant of ZstdOutputStream.
  - 612fa54f678a0111f5d570a4dee6719ce5416f08 Per bazelbuild/bazel#15416 (comment)...
  - 75ba8f73206dc4404cd3ff3554e7d3cd867eddb4 Remove obsolete j2objc_library docstring.
  - 1941dc1551e263d7d23419a6de2893bc76332bc8 Document @ as allowed in a package name
  - 24329485397ff03c4733a59278056d297006fc5a Add support for param files for Android NDK
  - 1a7083ebc76ab4c7100cc92913555596ffdc2049 Set correct rule name for `enable_data_binding` attribute...
  - f923a5bb1617045aecbc6babcc43b696bc192a6d Ensure Chunkers are always reset (closed).
  - 24f962bc8c9c0c8466e7d513bdd93e0c60e2532a Ignore specific warning from library desugaring
  - 1e405417457210191a4f4b3a7ce7950720a16cc7 Let Starlark executable rules specify their environment
  - 8746d45240cc3973979916594793ecc2092fe533 Pass `-Dsun.io.useCanonCaches=false` to JavaBuilder
  - 2217b13cae4110b0e2b8fe6a283a9b6dfbf150e8 Add `add_exports` and `add_opens` to `java_` rules
  - 11ec2267a9369d87841487744135e80991ba3d17 BazelModuleInspectorValue SkyValue added
  - 05f9dd184bcf2ef27aa63a9b0ba7521d1688d010 BazelModuleResolutionValue also stores the un-pruned dep ...
  - e828f9681803d98153313e97f95c82f28f11706d originalDeps map added to Module
  - 5bab7ef24672b815c486f390227187a33797e335 fix for bazelbuild/bazel#15465
  - 75bb463ab73f5f7cc60e7cc445ba24b377f4963f Make  --experimental_keep_config_nodes_on_analysis_discar...
  - 326baa299c283e05078780c597cc9cd530213d85 Automatic code cleanup.
  - ff195d3c023e79a38668d97df92526ceb3ce0bf0 Implement SourceManifestAction.describeKey to show better...
  - 478843fa3bc1c0ccefd20905bb6bfdadb9f9c744 Do not check extra local spawn whether it can be executed...
  - ae47bc24985384ebb7714c152945f40854cb60d8 Fix aspect toolchains when used over output files.
  - b6a45247c382b66d73756a5cc23251c8909f8e88 Restructure java_lite_proto_library by implementing it on...
  - 5f9ca4a04967215390f77511a628644eaae8d316 Update Bazel's Bzlmod build
  - a226eed7a48aa3637c8846b475cf429b0b41caf7 Remote: Fix the issue that partial downloaded inputs are ...
  - a0cb25beffc55bb5309caa4cb863986474f84c57 Automatic code cleanup.
  - 156d9c092c9c6f7985c601c38709ede3992dae06 Bzlmod: Built-in modules
  - 2ad10c38e8f4ce794d8763fcec4fe88efb15f2fb Remove java tools dependencies from additional_distfiles
  - 519d2daacfff3de6ffabfc5827621fa835e1c815 SolibSymlinkAction does not need exec platform or propert...
  - b4b8b2614ae854651075506666f109d0fc508ad1 Add experimental flag to include spawn metrics in the exe...
  - 1127316e2326fb5fc3145f1a259c674397bf0d8a Make the documentation of --experimental_allow_uinresolve...
  - f02e2fad3d12955ce0b2b808b1d0d7c3cffb4f4f Consistent min API level for desugar and dexing
  - 4d382b73d98c1910245dc89f8e3af010f0d56494 Cache StarlarkDefinedAspect AspectDefinitons
  - 075c5a33d34eed5fc56dd65a5e542df9180f6069 Make ManifestMergerAction worker compatible
  - 22db69a9f20e9d4625c35efe26760a369bf5d1e9 Improve error message for Android tests
  - 921d79e9d419508f60cc8a96181f38176ff6be03 Replace calls to java_proto_common with proto_common in j...
  - 6b6c63ed9fb5d51a90b91dca4bed5a68955a6859 Remove --incompatible_proto_output_v2.
  - 0686e03f8ceda3cb751b1d102ce9db08968faca4 Remove runtime Java dep from rule implementation of java_...
  - ae523f82d39daf01cf31e40733de0c6345f0935c Use tree artifacts in bootclasspath rule
  - b227a9a92c3b1f29c7db7c2f2f0881e36b7fdc5b Automatic code cleanup.
  - 4a054649a2180d1163934c521aa1da2aa8be6658 Add back an explanatory comment
  - f5ed7d0818946c7a36847d5bb5feef0b190e5b73 Traverse parent DexClassLoaders for native libraries in D...
  - 001bbdc3c462b6c11fad25b0ab6eddee8b044a6a Remove `test_` prefix from `CommandLinesTest`.
  (And 11 more changes)

BAZEL_VERSION_REV_ID: 8cea7651b8f08c06a5fe9c085bef6899fe084517
Change-Id: Ib02c02513702356a83c4ab707475f2d5b44185b5
ca4a626

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

Copybara

A tool for transforming and moving code between repositories.

Copybara is a tool used internally at Google. It transforms and moves code between repositories.

Often, source code needs to exist in multiple repositories, and Copybara allows you to transform and move source code between these repositories. A common case is a project that involves maintaining a confidential repository and a public repository in sync.

Copybara requires you to choose one of the repositories to be the authoritative repository, so that there is always one source of truth. However, the tool allows contributions to any repository, and any repository can be used to cut a release.

The most common use case involves repetitive movement of code from one repository to another. Copybara can also be used for moving code once to a new repository.

Examples uses of Copybara include:

  • Importing sections of code from a confidential repository to a public repository.

  • Importing code from a public repository to a confidential repository.

  • Importing a change from a non-authoritative repository into the authoritative repository. When a change is made in the non-authoritative repository (for example, a contributor in the public repository), Copybara transforms and moves that change into the appropriate place in the authoritative repository. Any merge conflicts are dealt with in the same way as an out-of-date change within the authoritative repository.

Currently, the only supported type of repository is Git. Copybara also supports reading from Mercurial repositories, but the feature is still experimental. Support for other repositories types will be added in the future.

Example

core.workflow(
    name = "default",
    origin = git.github_origin(
      url = "https://github.com/google/copybara.git",
      ref = "master",
    ),
    destination = git.destination(
        url = "file:///tmp/foo",
    ),

    # Copy everything but don't remove a README_INTERNAL.txt file if it exists.
    destination_files = glob(["third_party/copybara/**"], exclude = ["README_INTERNAL.txt"]),

    authoring = authoring.pass_thru("Default email <default@default.com>"),
    transformations = [
        core.replace(
                before = "//third_party/bazel/bashunit",
                after = "//another/path:bashunit",
                paths = glob(["**/BUILD"])),
        core.move("", "third_party/copybara")
    ],
)

Run:

$ (mkdir /tmp/foo ; cd /tmp/foo ; git init --bare)
$ copybara copy.bara.sky

Getting Started using Copybara

Copybara doesn't have a release process yet, so you need to compile from HEAD. In order to do that, you need to do the following:

  • Install JDK 11.
  • Install Bazel.
  • Clone the copybara source locally:
    • git clone https://github.com/google/copybara.git
  • Build:
    • bazel build //java/com/google/copybara
    • bazel build //java/com/google/copybara:copybara_deploy.jar to create an executable uberjar.
  • Tests: bazel test //... if you want to ensure you are not using a broken version.

System packages

These packages can be installed using the appropriate package manager for your system.

Arch Linux

Using Intellij with Bazel plugin

If you use Intellij and the Bazel plugin, use this project configuration:

directories:
  copybara/integration
  java/com/google/copybara
  javatests/com/google/copybara
  third_party

targets:
  //copybara/integration/...
  //java/com/google/copybara/...
  //javatests/com/google/copybara/...
  //third_party/...

Note: configuration files can be stored in any place, even in a local folder. We recommend using a VCS (like git) to store them; treat them as source code.

Building Copybara in an external Bazel workspace

There are convenience macros defined for all of Copybara's dependencies. Add the following code to your WORKSPACE file, replacing {{ sha256sum }} and {{ commit }} as necessary.

http_archive(
  name = "com_github_google_copybara",
  sha256 = "{{ sha256sum }}"
  strip_prefix = "copybara-{{ commit }}",
  url = "https://github.com/google/copybara/archive/{{ commit }}",
)

load("@com_github_google_copybara//:repositories.bzl", "copybara_repositories")

copybara_repositories()

load("@com_github_google_copybara//:repositories.maven.bzl", "copybara_maven_repositories")

copybara_maven_repositories()

load("@com_github_google_copybara//:repositories.go.bzl", "copybara_go_repositories")

copybara_go_repositories()

You can then build and run the Copybara tool from within your workspace:

bazel run @com_github_google_copybara//java/com/google/copybara -- <args...>

Using Docker to build and run Copybara

NOTE: Docker use is currently experimental, and we encourage feedback or contributions.

You can build copybara using Docker like so

docker build --rm -t copybara .

Once this has finished building, you can run the image like so from the root of the code you are trying to use Copybara on:

docker run -it -v "$(pwd)":/usr/src/app copybara copybara

A few environment variables exist to allow you to change how you run copybara:

  • COPYBARA_CONFIG=copy.bara.sky
    • allows you to specify a path to a config file, defaults to root copy.bara.sky
  • COPYBARA_SUBCOMMAND=migrate
    • allows you to change the command run, defaults to migrate
  • COPYBARA_OPTIONS=''
    • allows you to specify options for copybara, defaults to none
  • COPYBARA_WORKFLOW=default
    • allows you to specify the workflow to run, defaults to default
  • COPYBARA_SOURCEREF=''
    • allows you to specify the sourceref, defaults to none
docker run \
    -e COPYBARA_CONFIG='other.config.sky' \
    -e COPYBARA_SUBCOMMAND='validate' \
    -v "$(pwd)":/usr/src/app \
    -it copybara copybara

Git Config and Credentials

There are a number of ways by which to share your git config and ssh credentials with the Docker container, an example with macOS is below:

docker run \
    -v ~/.ssh:/root/.ssh \
    -v ~/.gitconfig:/root/.gitconfig \
    -v "$(pwd)":/usr/src/app \
    -it copybara copybara

Documentation

We are still working on the documentation. Here are some resources:

Contact us

If you have any questions about how Copybara works, please contact us at our mailing list.

Optional tips

  • If you want to see the test errors in Bazel, instead of having to cat the logs, add this line to your ~/.bazelrc:

    test --test_output=streamed
    

About

Copybara: A tool for transforming and moving code between repositories.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published