doGit.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 # run simple git commands on each repository in MRB_SOURCE
4 
5 
6 # Determine this command name
7 thisComFull=$(basename $0)
8 ##thisCom=${thisComFull%.*}
9 fullCom="${thisComFull%.*}"
10 
11 # Usage function
12 function usage() {
13  echo "Usage: $fullCom <command>"
14 }
15 
16 # Determine command options (just -h for help)
17 while getopts ":h" OPTION
18 do
19  case $OPTION in
20  h ) usage ; exit 0 ;;
21  * ) echo "ERROR: Unknown option" ; usage ; exit 1 ;;
22  esac
23 done
24 
25 # Capture the tag
26 gitcmd=${1}
27 if [ -z "${gitcmd}" ]
28 then
29  echo 'ERROR: no options specified'
30  usage
31  exit 1
32 fi
33 
34 
35 if [ -z "${MRB_SOURCE}" ]
36 then
37  echo 'ERROR: MRB_SOURCE must be defined'
38  echo ' source the appropriate localProductsXXX/setup'
39  exit 1
40 fi
41 
42 if [ ! -r $MRB_SOURCE/CMakeLists.txt ]; then
43  echo "$MRB_SOURCE/CMakeLists.txt not found"
44  exit 1
45 fi
46 
47 # find the directories
48 # ignore any directory that does not contain ups/product_deps
49 list=`ls $MRB_SOURCE -1`
50 for file in $list
51 do
52  if [ -d $file ]
53  then
54  if [ -r $file/ups/product_deps ]
55  then
56  pkglist="$file $pkglist"
57  fi
58  fi
59 done
60 
61  for REP in $pkglist
62  do
63  echo
64  echo "${REP}: git ${gitcmd}"
65  cd ${MRB_SOURCE}/${REP} || exit 1
66  git ${gitcmd}
67  okflow=$?
68  if [ ! ${okflow} ]
69  then
70  echo "${REP} git ${gitcmd} failure: ${okflow}"
71  exit 1
72  fi
73  done
74 
75 exit 0