Continued a bit:
[jprojects-scripts.git] / push-stick.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 TARGETS="o d t u"
6 FORCE="--force"
7
8 if [ "$1" = "a" ]
9 then
10         cd "${JPROJECTS_HOME}"
11         for TARGET in ${TARGETS}; do
12                 echo "$0: Pushing for target '${TARGET}' ..."
13                 $0 "${TARGET}" "$2"
14         done
15
16         echo "$0: Pushed to all targets."
17         exit 0
18 fi
19
20 for project in ${LIST}; do
21         if [ ! -d "${JPROJECTS_HOME}/${project}" ]
22         then
23                 echo "$0: Project '${project}' does not exist."
24                 continue;
25         fi
26
27         echo "$0: Processing '${project}',mode='$1' ..."
28         cd "${JPROJECTS_HOME}/${project}" || exit 255
29
30         if [ "$1" = "d" ]
31         then
32                 if [ -n "$2" ]
33                 then
34                         git push daedalus :"$2"
35                 fi
36
37                 git push ${FORCE} --all daedalus || exit 255
38         elif [ "$1" = "t" ]
39         then
40                 if [ -n "$2" ]
41                 then
42                         git push transport :"$2"
43                         echo "$0: Syncing ..."
44                         sync
45                 fi
46
47                 git push ${FORCE} --all transport || exit 255
48                 echo "$0: Syncing ..."
49                 sync
50         elif [ "$1" = "u" ]
51         then
52                 if [ -n "$2" ]
53                 then
54                         git push upstream :"$2"
55                 fi
56
57                 git push ${FORCE} --all upstream || exit 255
58         else
59                 if [ -n "$2" ]
60                 then
61                         git push origin :"$2"
62                         echo "$0: Syncing ..."
63                         sync
64                 fi
65
66                 git push ${FORCE} --all || exit 255
67                 echo "$0: Syncing ..."
68                 sync
69         fi
70 done
71
72 echo "$0: All done."
73 exit 0