How to make a copy of a git repository and all it's submodules into gerrit server?

166 views
Skip to first unread message

Makson Lee

unread,
Oct 27, 2022, 11:27:12 PM10/27/22
to Repo and Gerrit Discussion
Compares to git repositories managed by repo tool, it is hard to make a copy of a git repository and all it's submodules into gerrit server.

For example, if branch of a submodules is a commit id, then we don't know which branch we should create in gerrit server.

Any experience can be shared or any suggestions?

Seyoung Song

unread,
Oct 29, 2022, 12:14:54 AM10/29/22
to Repo and Gerrit Discussion
I use copybara; https://github.com/google/copybara.

copy.bara.sky
===
core.workflow(
name = "repo1",
origin = git.origin(
url = "https://<repo1-url>",
ref = "master",
submodules = 'RECURSIVE',
),
destination = git.destination(
url = "https://<gerrit-repo-url>",
fetch = "main",
push = "main",
),
destination_files = glob(["repo1/**"]),
authoring = authoring.pass_thru("Copybara <copy...@example.com>"),
transformations = [
core.move("", "/repo1"),
],
)
===

java -Djavax.net.ssl.trustStore=<store file> -Djavax.net.ssl.trustStorePassword=<password> -jar ~/bin/copybara_deploy.jar migrate -v copy.bara.sky --force repo1

This copies repo1 under /repo1 directory of gerrit repo.
All files in submodule links are recursively copied.

I copy to /repo1 directory because my gerrit repo is monorepo and I copy many other repos in one gerrit repo.

Makson Lee

unread,
Oct 30, 2022, 8:41:38 PM10/30/22
to Repo and Gerrit Discussion
Thanks for the information, i will try it.
Reply all
Reply to author
Forward
0 new messages