我在服务器上有一个post-receive
挂钩:
#!/bin/sh
cd /var/www/project/sources || exit 1
unset GIT_DIR
git pull hub master
我在/ project / source上有一个post-merge
挂钩:
#!/bin/sh
sh /var/git/hooks-scripts/clean /var/www/project/sources
当我运行git push
时,一切正常,除了我的/var/git/hooks-scripts/clean
脚本的输出在完成所有内容时发送,而不是逐行发送。如何逐行输出?
编辑:
根据要求,干净的脚本
#!/bin/bash
# define composer cache firectory
export COMPOSER_CACHE_DIR="/tmp/.composer-cache"
no_color="\\033[0;39m"
blue="\\033[1;34m"
yellow="\\033[1;33m"
green="\\033[0;32m"
end_script() {
echo "\n${yellow}*** Configuration du projet ${blue}BAO${yellow} terminé ***${no_color}\n"
exit $1
}
check_run() {
echo "$changed_files" | grep --quiet "$1" && echo " * changes detected in $1" && echo " * running $2" && eval "$2"
}
echo "\n${yellow}*** Configuration du projet ${blue}BAO${yellow} en cours ***${no_color}\n"
cd $1/scripts/cli || end_script 0
php console.php clean cache
php console.php clean thumbnails
php console.php symlink modules
cd $1
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)"
check_run composer.lock "composer update -q -o"
echo "${green}✔${no_color} done"
end_script 0