Guest User

git.sh

a guest
May 8th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.85 KB | None | 0 0
  1. #!/bin/bash
  2. SOURCE=`pwd`
  3. echo "Fast Git Project Updates 0.1"
  4. tab=($(find -maxdepth 3 -type d -name '.git'))
  5. echo "Detect" ${#tab[*]} "projects in "$SOURCE
  6. for dir in ${tab[*]};
  7. do
  8.     dir=${dir:0:-4}
  9.     if [ "$1" = "update" ]
  10.     then
  11.         echo -e "\E[32mUpdate " ${dir:2:-1} "\033[0m"
  12.         cd $dir
  13.         git pull > output
  14.         a=`cat output`
  15.         if [ "$a" = "Already up-to-date." ]
  16.         then
  17.             echo "No updates!"
  18.         fi
  19.         rm output
  20.         cd $SOURCE
  21.     elif [ "$1" = "upgrade" ]
  22.     then
  23.         echo -e "\E[32mUpgrade " ${dir:2:-1} "\033[0m"
  24.         cd $dir
  25.         if [ -e "CMakeLists.txt" ]
  26.         then
  27.             echo "Run Cmake"
  28.             cmake .
  29.         elif [ -e "configure" ]
  30.         then
  31.             echo "Run configure"
  32.             configure .
  33.         fi
  34.         if [ -e "Makefile" ]
  35.         then
  36.             echo "Run make"
  37.             make
  38.         fi
  39.         cd $SOURCE
  40.     elif [ "$1" = "install" ]
  41.     then
  42.         if [ "$2" != "" ]
  43.         then
  44.             git clone $2
  45.         fi
  46.     fi
  47. done
Advertisement
Add Comment
Please, Sign In to add comment