如何使 Gitolite post-receive 挂钩显示修改文件的完整路径?

How can I make Gitolite post-receive hook to show full path to modified file?

这是我的 post-接收挂钩:

#!/bin/bash

while read oldrev newrev ref; do
        git diff --name-only oldrev..newrev
        git --work-tree=/tmp checkout HEAD -- plugin.yml
        echo -e "Test complete maybe..." | tee >(exec logger)
done

这是输出:

如果我将 oldrev..newrev 替换为 oldrev -- newrev,则输出为:

我需要获取修改此文件(plugin.yml) 的文件夹。谢谢

首先,每个挂钩都可以简单地检查它的 execution path:这将为您提供存储库的名称。

其次,git diff --name-only I mentioned in your previous question会给你推送文件的相对路径(包括mod1/2)。

git diff --name-only ..

因为 post-receive 挂钩在标准输入上接收 oldrevnewrevref