我怎样才能让Gitolite post-receive hook显示修改文件的完整路径? [英] How can I make Gitolite post-receive hook to show full path to modified file?

查看:133
本文介绍了我怎样才能让Gitolite post-receive hook显示修改文件的完整路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 #!/ bin / bash 

while阅读oldrev newrev ref; do
git diff --name-only oldrev..newrev
git --work-tree = / tmp checkout HEAD - plugin.yml
echo -eTest complete maybe ... | tee>(执行记录器)
完成

这里是输出:





如果我用oldrev替换oldrev..newrev - - newrev,输出是:



我需要获取该文件所在的文件夹(插件。 yml)被修改了。首先,每个钩子都可以简单地检查它的 其次, git diff --name-only 我在你以前的问题会给你推送文件的相对路径(包括 mod1 / 2 )。

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

因为post-receive钩子收到 oldrev newrev ref 标准输入。


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.

解决方案

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.

这篇关于我怎样才能让Gitolite post-receive hook显示修改文件的完整路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆