首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Gerrit复制到GitLab

从Gerrit复制到GitLab
EN

Stack Overflow用户
提问于 2021-10-22 18:07:15
回答 1查看 453关注 0票数 0

我想配置从Gerrit到GitLab的复制。对于“商业”项目,它工作得很好。但对于“默认”用户(所有项目和所有用户)来说,这是行不通的。“业务”项目名称与Gerrit和GitLab格式的“组/项目”相同。

我的replication.config文件:

代码语言:javascript
复制
[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

代码语言:javascript
复制
[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这样的回购。但是有gitlab.local:external-tools/gerrit-All-Projects.git,用于复制的用户具有主级别的权限。

当我试图检查复制状态时,下面是我得到的信息:

代码语言:javascript
复制
$ 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. 排除remote "GitLab"中所有项目和所有用户的复制(以保持日志干净)
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-03 12:43:23

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

代码语言:javascript
复制
[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

来自插件文档remote.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,因此您必须复制refs/*。见下面的例子:

代码语言:javascript
复制
> 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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69681356

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档