Git钩子:启用回显命令 [英] Git hook: enable echoing commands

查看:129
本文介绍了Git钩子:启用回显命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以在git hook中启用echo

  /var/git/repositories/project.git/hooks/更新后

#!/ bin / bash
未设置GIT_DIR;
echo'======== post-update hook ========='

cd / var / project;
git reset --hard;
git checkout testing;
git pull;
chmod -R 774 ./lib

update-apps

希望在另一个mashine上使用git push output:

  #git push 
...
写入对象: 100%(10/10),5.98KIB,完成。
合计10(delta 3),重用8(delta 1)
========后更新钩子=========
cd / var /项目
git reset --hard
git checkout testing
git pull
chmod -R 774 ./lib
update-apps

这只是一个例子,实际的命令链可能会更复杂。某处



是否应该将stdout重定向到stderr?
$ b 更新



目前我有普通的 git push 输出,然后是 ======== post-更新钩子=========
...没有任何东西



哦! git version is 1.5.6.5

解决方案

stdout或stderr上的所有输出都应该被转发。它预计适用于所有预收,更新 post-receive code>和后更新钩子。在bourne shell中使用 set -x 启用回声命令。


is there any way to enable echo in git hook

/var/git/repositories/project.git/hooks/post-update

#!/bin/bash
unset GIT_DIR;
echo '========post-update hook========='

cd /var/project;
git reset --hard;
git checkout testing;
git pull;
chmod -R 774 ./lib

update-apps

desired git push output on another mashine:

#git push
...
Writing objects: 100% (10/10), 5.98 KiB, done.
Total 10 (delta 3), reused 8 (delta 1)
========post-update hook=========
cd /var/project
git reset --hard
git checkout testing
git pull
chmod -R 774 ./lib
update-apps

this is just an example, actual command chain can be more complicated

and fail somewhere

should I redirect stdout to stderr somehow?

UPDATE

currently I have normal git push output and then ========post-update hook========= ... and nothing

Oh! git version is 1.5.6.5

解决方案

All output on either stdout or stderr should be forwarded. It's expected to work for all of pre-receive, update, post-receive and post-update hooks. Echoing commands is enabled with set -x in bourne shell.

这篇关于Git钩子:启用回显命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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