是否可以删除Gerrit Code Review中的组?可能是一些插件,或者应该手动执行此操作'以类似SQL的方式(例如gerrit gsql)?
答案 0 :(得分:4)
很遗憾,没有办法使用command line tools或REST API删除Gerrit群组。
我有一个从Gerrit数据库中删除Gerrit组的脚本。
它主要执行以下操作:
1)检查Gerrit中是否存在该组:
if ssh -p 29418 USER@GERRIT-SERVER gerrit ls-groups -q GROUP > /dev/null
then
# GROUP EXIST
else
# GROUP DOESN'T EXIST
fi
2)检查该组是否具有在任何项目中分配的访问权限:
ssh -p 29418 USER@GERRIT-SERVER gerrit ls-projects --type ALL --has-acl-for GROUP > /tmp/ls-projects
if [[ -s /tmp/ls-projects ]]
then
# GROUP HAS ACCESS RIGHTS ASSIGNED
else
# GROUP DOESN'T HAVE ACCESS RIGHTS ASSIGNED
fi
注意:您首先需要从任何项目访问权限中删除该组。
3)在Gerrit数据库中搜索组ID
SELECT group_id FROM account_group_names WHERE name = 'GROUP';
4)从Gerrit数据库中删除该组
START TRANSACTION;
DELETE FROM account_group_id WHERE s = 'GROUP-ID';
DELETE FROM account_group_by_id WHERE group_id = 'GROUP-ID';
DELETE FROM account_group_by_id_aud WHERE group_id = 'GROUP-ID';
DELETE FROM account_group_members WHERE group_id = 'GROUP-ID';
DELETE FROM account_group_names WHERE group_id = 'GROUP-ID';
DELETE FROM account_groups WHERE group_id = 'GROUP-ID';
DELETE FROM account_group_members_audit WHERE group_id = 'GROUP-ID';
COMMIT;