From: Barış Metin Date: Thu, 14 Oct 2010 13:29:00 +0000 (+0200) Subject: report the status (conflict) and failed commands X-Git-Tag: foo~73 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=e39f99e87e04b9611940aefaac24ecff1665861c;p=infrastructure.git report the status (conflict) and failed commands --- diff --git a/scripts/git-mirror.sh b/scripts/git-mirror.sh index 42ab22c..8ebae5b 100755 --- a/scripts/git-mirror.sh +++ b/scripts/git-mirror.sh @@ -6,6 +6,7 @@ MASTER_GIT="/git" LOCAL_MIRROR_DIR="/git-mirror" QUIET=0 FAILED=0 +FAILED_CMDS="" function msg () { if [ $QUIET -eq 0 ] @@ -15,9 +16,11 @@ function msg () { } function error () { + SUBJECT=$1 + MSG=$2 for admin in $ADMINS do - echo "[ERROR] xxxxxxxxxxx $@" | mail -s "$@" $admin + echo -e "$MSG" | mail -s "$SUBJECT" $admin done } @@ -36,14 +39,17 @@ function run () { if [ $? -ne 0 ] then FAILED=1 + FAILED_CMDS="$FAILED_CMDS\n$COMMAND" fi popd > /dev/null } function run_ignore_errors () { OLD_FAILED=$FAILED + OLD_FAILED_CMDS=$FAILED_CMDS run "$1" "$2" FAILED=$OLD_FAILED + FAILED_CMDS=$OLD_FAILED_CMDS } function merge_all_branches () { @@ -117,7 +123,10 @@ function mirror () { merge_all_branches $NAME local_master $REPO_DIR if [ $FAILED -ne 0 ] then - error "git-mirror.sh failed on ${MIRROR_REPO}" + pushd ${REPO_DIR} > /dev/null + STATUS_OUT=$(git status) + popd > /dev/null + error "git-mirror.sh failed on ${MIRROR_REPO}" "STATUS:\n$STATUS_OUT \n\n------------\n FAILED COMMANDS:\n$FAILED_CMDS" else run "git push --tags local_master" ${REPO_DIR} push_all_branches $NAME local_master $REPO_DIR