report the status (conflict) and failed commands
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 14 Oct 2010 13:29:00 +0000 (15:29 +0200)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 14 Oct 2010 13:29:00 +0000 (15:29 +0200)
scripts/git-mirror.sh

index 42ab22c..8ebae5b 100755 (executable)
@@ -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