简体   繁体   English

Git hook:启用echoing命令

[英]Git hook: enable echoing commands

is there any way to enable echo in git hook 有没有办法在git hook中启用echo

/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: 另一个mashine所需的git push输出:

#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? 我应该以某种方式将stdout重定向到stderr吗?

UPDATE UPDATE

currently I have normal git push output and then ========post-update hook========= ... and nothing 目前我有正常的git push输出然后========post-update hook========= ...什么都没有

Oh! 哦! git version is 1.5.6.5 git版本是1.5.6.5

All output on either stdout or stderr should be forwarded. 应转发stdout或stderr上的所有输出。 It's expected to work for all of pre-receive , update , post-receive and post-update hooks. 它预计适用于所有pre-receiveupdatepost-receive post-update挂钩。 Echoing commands is enabled with set -x in bourne shell. 在bourne shell中使用set -x启用了回显命令。

From githooks manual: 来自githooks手册:

Both standard output and standard error output are forwarded to git send-pack on the other end, so you can simply echo messages for the user. 标准输出和标准错误输出都转发到另一端的git send-pack,因此您可以简单地为用户回显消息。

But there was a know issue in some earlier versions of Git and also earlier version of Smart HTTP, whereby the output was not send. 但是在一些早期版本的Git以及早期版本的Smart HTTP中存在一个已知问题,即输出未发送。 Update your git version and try. 更新您的git版本并尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM