Merge branch 'master' of git.mxchange.org:/var/cache/git/repos/jprojects-scripts
[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                 fi
44
45                 git push ${FORCE} --all transport || exit 255
46         elif [ "$1" = "u" ]
47         then
48                 if [ -n "$2" ]
49                 then
50                         git push upstream :"$2"
51                 fi
52
53                 git push ${FORCE} --all upstream || exit 255
54         else
55                 if [ -n "$2" ]
56                 then
57                         git push origin :"$2"
58                 fi
59
60                 git push ${FORCE} --all || exit 255
61         fi
62 done
63
64 echo "$0: All done."
65 exit 0