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

断了今生、忘了曾经 提交于 2019-12-08 05:19:00

问题


Here is my post-receive hook:

#!/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

And here is the output:

And if I replace oldrev..newrev by oldrev -- newrev, the output is:

I need to get folder in which this file(plugin.yml) was modified. Thanks.


回答1:


First, each hook can simply check its execution path: that will give you the name of the repo.

Second, the git diff --name-only I mentioned in your previous question will give you the relative path of the file being pushed (including mod1/2).

git diff --name-only $1..$2

since the post-receive hook receives oldrev, newrev and ref on standard input.



来源:https://stackoverflow.com/questions/45290215/how-can-i-make-gitolite-post-receive-hook-to-show-full-path-to-modified-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!