summaryrefslogtreecommitdiff
path: root/git_multi.sh
blob: 3772aff0380a1ed849a35f7d06a843787a8c96b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

#Change the list of repos.
REPOS="core/efl core/elementary core/enlightenment core/evas_generic_loaders core/emotion_generic_players"
REPOS+=" apps/ecrire apps/terminology devs/tasn/solve"
REPOS+=" tools/clouseau"
#REPOS="legacy/ecore legacy/edbus legacy/edje legacy/eet legacy/eeze legacy/efreet legacy/eina legacy/eio legacy/embryo legacy/emotion legacy/ephysics legacy/ethumb legacy/evas legacy/evil"
#Change to 1 if you have dev access.
DEV_ACCESS=0


###############################################################################
# Actual code, don't touch:

usage()
{
   echo "Usage : $0 <pull|clone>"
   exit 1
}

clone_repos()
{
   BASE_URL="git://git.enlightenment.org"
   if [ "$DEV_ACCESS" -eq 1 ]; then
      BASE_URL="git+ssh://git@git.enlightenment.org"
   fi

   echo "Using base URL: '${BASE_URL}'"

   for REPO in $REPOS ; do
      if [ ! -d "$REPO" ]; then
	 mkdir -p "${REPO}"
         git clone "${BASE_URL}/${REPO}.git" "${REPO}"
      else
         echo "Skipping existing repo: ${REPO}"
      fi
   done
}

run_command_in_dirs()
{
   CMD=$1
   for REPO in $REPOS ; do
      if [ -d "$REPO" ]; then
	 echo "Processing command in ${REPO}"
         pushd ${REPO} &>/dev/null
         eval $CMD
         popd &>/dev/null
      else
         echo "Skipping non-existent dir: ${REPO}"
      fi
   done
}

if [ $# -lt 1 ]; then
   usage
fi

case "$1" in
   pull)
      run_command_in_dirs "git pull --rebase"
      ;;
   clone)
      clone_repos
      ;;
   run)
      if [ -z "$2" ]; then
         echo "'$1' accepts an additional 'command' parameter."
         exit 1
      fi
      run_command_in_dirs "$2"
      ;;
   *)
      usage
      ;;
esac