我想编辑gitolite3的配置文件,它是用perl编写的,看起来像:
# comments
# comments
%RC = (
# ------------------------------------------------------------------
# comments
UMASK => 0077,
# comments
GIT_CONFIG_KEYS => '',
# comments
ROLES => {
READERS => 1,
WRITERS => 1,
},
# comments
ENABLE => [
# comments
'help',
'desc',
'info',
'perms',
'writable',
# comments
],
);
# ------------------------------------------------------------------------------
# comments
1;
# comments
如果没有可用的augeas,我需要一些保存评论的东西——它们对我和未来的管理员来说都很方便。
由于gitolite.rc直接是一个关联数组,您可以考虑用perl编写实用程序。
src/lib/Gitolite/Rc.pm
已经向您展示了如何加载该文件,它提供了一种查询键/值的方法:
Usage: gitolite query-rc -a
gitolite query-rc [-n] [-q] rc-variable
-a print all variables and values (first level only)
-n do not append a newline if variable is scalar
-q exit code only (shell truth; 0 is success)
但是,您可以通过添加键/值并写回配置来扩展这些功能。