×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Bash
Posted by: Gerrit Viljoen
Added: Sep 25, 2014 12:08 PM
Modified: Oct 10, 2014 10:47 AM
Views: 25
From the specified directory, recursively check repos for changes between local and remote.
  1. #!/bin/bash
  2.  
  3. if [[ -z "$@" ]]
  4. then
  5.     dir=$(readlink -f .)
  6. elif [[ -d "$@" ]]
  7. then
  8.     dir=$(readlink -f "$@")
  9. elif [[ -f "$@" ]]
  10. then
  11.     dir=$(dirname "$@" | xargs readlink -f)
  12. else
  13.     dir=$(readlink -f .)
  14. fi
  15.  
  16. for file in $(find "$dir" -type d -not -path '*/.*' -printf '%p ')
  17. do
  18.     if [[ -d "$file/.git" ]]
  19.     then
  20.         echo ">> $file"
  21.         cd "$file"
  22.         git fetch origin && git diff --stat --stat-count=1000 origin/master master
  23.         echo "<<"
  24.     fi
  25. done
  26.