reference:https://blog.bruin.sg/2013/04/19/how-to-edit-the-project-config-for-all-projects-in-gerrit/
背景
有時候需要重新配置Gerrit;如果將所有的項目都重新手動配一遍,是比較麻煩的。在網上找到了配置方法。
思路:由於項目設置保存在項目的Git存儲庫中,因此可以通過gerrit附帶的ssh操作,在從Gerrit克隆項目、進行更改,再commit以及push到Gerrit來實現修改。
PROJECT=你需要修改權限的項目名,如果希望所有項目都可以生效,則修改`All-Projects`。
$ mkdir gerrit_config # 目錄無所謂
$ cd gerrit_config
$ git init
$ git remote add origin ssh://<USER>@<GERRITHOST>:29418/<PROJECT>
$ git fetch origin refs/meta/config:refs/remotes/origin/meta/config
remote: Counting objects: 7, done
remote: Finding sources: 100% (7/7)
remote: Total 7 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From ssh://10.88.105.12:29418/All-Projects
* [new ref] refs/meta/config -> origin/meta/config
git checkout meta/config
此后,可以看到兩個文件,一個跟組名有關,一個與當前項目的配置有關:
通常,在
http://<GERRITHOST>:<PORT>:8080/plugins/gitiles/
中可以看到有關的改動。
$ ls
groups project.config
最后,將其提交即可(確保有項目對應的訪問權限)。
git commit -a
git push origin meta/config:meta/config
此后,可以看到對應的提交:
http://<GERRITHOST>:<PORT>:8080/plugins/gitiles/
9123049 test by schips · 21 seconds ago
b3fec78 Configure 'Verified' label by Gerrit Code Review · 5 days ago
b42a8c3 Initialized Gerrit Code Review 3.1.4 by Gerrit Code Review · 5 days ago