跳转至

Gerrit 定制项目下载命令

概要: 自定义获取commit-msg脚本的命令

创建时间: 2022.12.21 23:56:43

更新时间: 2023.05.20 21:07:14

commit-msg作用

生成变更单号,即 ChangeID

commit-msg从哪里来

默认配置下,commit-msg和下载repo的命令,由Gerrit核心插件download-commands提供,根据其配置说明
image.png
如果使用自定义的命令,需要将 commit-msg 脚本托管到一处HTTP服务器上

自定义commit-msg下载命令

搭建HTTP服务器

略,此处假定将已有的 commit-msg 文件放到 http://192.168.2.145:9090/hooks/commit-msg 位置。

修改gerrit.config

按照插件文档说明,修改 [gerrit] 下的 installCommitMsgHookCommand 字段如下

Properties
[gerrit]
    installCommitMsgHookCommand = "wget -qO $(git rev-parse --git-dir)/hooks/commit-msg http://192.168.2.145:18765/hooks/commit-msg; chmod a+x $(git rev-parse --git-dir)/hooks/commit-msg"
保存文件后,最后重启Gerrit强制刷新配置

效果

此时查看下载命令,变为如下

Bash
git clone "ssh://lz-wang@192.168.2.145:8080/All-Projects" && (cd "All-Projects" && wget -qO $(git rev-parse --git-dir)/hooks/commit-msg http://192.168.2.145:9090/hooks/commit-msg; chmod a+x $(git rev-parse --git-dir)/hooks/commit-msg)

参考