从 Gerrit 复制到 GitLab

Replication from Gerrit to GitLab

我想配置从 Gerrit 到 GitLab 的复制。对于“商业”项目,它工作正常。但是对于“默认”的(所有项目和所有用户)它不起作用。 “业务”项目名称与 Gerrit 和 GitLab 中的名称相同 - 格式为“group/project”。

我的 replication.config 文件:

[gerrit]
    autoReload = true
    replicateOnStartup = true
[remote "GitLab-All-Projects"]
    projects = All-Projects
    url = gitlab@gitlab.local:external-tools/gerrit-All-Projects.git
    push = +refs/heads/*:refs/heads/*
    push = +refs/tags/*:refs/tags/*
    threads = 3
    mirror = true
[remote "GitLab"]
    url = gitlab@gitlab.local:${name}.git
    push = +refs/heads/*:refs/heads/*
    push = +refs/tags/*:refs/tags/*
    threads = 3

我对 remote "GitLab-All-Projects" 有疑问。来自 replication_log:

[2021-10-22 19:57:46,038] Replication to gitlab@gitlab.local:All-Projects.git started... [CONTEXT pushOneId="7656717c" ]
[2021-10-22 19:57:46,303] Replication to gitlab@gitlab.local:All-Users.git started... [CONTEXT pushOneId="b6794909" ]
[2021-10-22 19:57:47,027] Created remote repository: gitlab@gitlab.local:All-Projects.git [CONTEXT pushOneId="7656717c" ]
[2021-10-22 19:57:47,027] Missing repository created; retry replication to gitlab@gitlab.local:All-Projects.git [CONTEXT pushOneId="7656717c" ]
[2021-10-22 19:57:47,295] Created remote repository: gitlab@gitlab.local:All-Users.git [CONTEXT pushOneId="b6794909" ]
[2021-10-22 19:57:47,296] Missing repository created; retry replication to gitlab@gitlab.local:All-Users.git [CONTEXT pushOneId="b6794909" ]

当然,在 GitLab 中没有像 gitlab.local:All-Projects.git 这样的回购协议。但是有 gitlab.local:external-tools/gerrit-All-Projects.git 并且用于复制的用户具有主级别权限。

当我尝试检查复制状态时,我得到的是:

$ ssh -p 29418 user@gerrit.local replication list --detail --json
{"Remote":"GitLab-All-Projects","Url":["gitlab@gitlab.local:external-tools/gerrit-All-Projects.git"],"Project":["All-Projects"]}
{"Remote":"GitLab","Url":["gitlab@gitlab.local:${name}.git"],"Pending":["(retry 1) [b6794909] push gitlab@gitlab.local:All-Users.git [..all..]","(retry 1) [7656717c] push gitlab@gitlab.local:All-Projects.git [..all..]"]}

我想:

  1. remote "GitLab-All-Projects"
  2. 中的所有项目和所有用户配置复制
  3. 排除 remote "GitLab" 内所有项目和所有用户的复制(以保持日志清洁)

您可以按如下方式修改您的 replication.config

[gerrit]
    autoReload = true
    replicateOnStartup = true
[remote "GitLab-All-Projects"]
    projects = All-Projects
    projects = All-Users
    url = gitlab@gitlab.local:external-tools/gerrit-${name}.git
    push = +refs/*:refs/*
    threads = 3
    mirror = true
[remote "GitLab"]
    projects = ^(?:(?!All-(Users|Projects)).)*$
    url = gitlab@gitlab.local:${name}.git
    push = +refs/*:refs/*
    threads = 3

来自插件 documentationremote.NAME.projects : Specifies which repositories should be replicated to the remote. It can be provided more than once, and supports three formats: regular expressions, wildcard matching, and single project matching. All three formats match case-sensitive.

请记住,All-* 项目不一定包含 refs/heads 命名空间下的引用,因此您必须复制 refs/*。请参阅下面的示例:

> pwd
 /tmp/gerrit/git/All-Projects.git
> git show-ref
 4c160a51808ec7ec253f125ea404c96302292940 refs/meta/config
 56a6051ca2b02b04ef92d5150c9ef600403cb1de refs/sequences/changes

> pwd
 /tmp/gerrit/git/All-Users.git
> git show-ref
 14711668d99dc83834cf2a83e6f3416bb1059321 refs/groups/5a/5a1e63b3d5542f55a25adaf390ca745b4335d995
 fdb77a3da3fbe131936161768c38f5d78deb54bd refs/groups/f7/f7ff10a4c7d8b4c3004f843fccdb2ca8decdc330
 278491ec14ecd9d856f194c0a3cc8e571a040bda refs/meta/config
 e2bc4638a57a79d63647a070a9fefcaed7628bae refs/meta/external-ids
 35a98b786adba41afb255a3b831d0bfaf62ac61f refs/meta/group-names
 44b2d5628ae9a825b22c86ed14f0ce6335ea888b refs/sequences/accounts
 e440e5c842586965a7fb77deda2eca68612b1f53 refs/sequences/groups
 c2e273e2356165687fa722fd938a0aeee3f5261e refs/users/00/1000000