簡體   English   中英

Git hook:啟用echoing命令

[英]Git hook: enable echoing commands

有沒有辦法在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

另一個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

這只是一個例子,實際的命令鏈可能更復雜

在某個地方失敗

我應該以某種方式將stdout重定向到stderr嗎?

UPDATE

目前我有正常的git push輸出然后========post-update hook========= ...什么都沒有

哦! git版本是1.5.6.5

應轉發stdout或stderr上的所有輸出。 它預計適用於所有pre-receiveupdatepost-receive post-update掛鈎。 在bourne shell中使用set -x啟用了回顯命令。

來自githooks手冊:

標准輸出和標准錯誤輸出都轉發到另一端的git send-pack,因此您可以簡單地為用戶回顯消息。

但是在一些早期版本的Git以及早期版本的Smart HTTP中存在一個已知問題,即輸出未發送。 更新您的git版本並嘗試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM