4eeb02ea9180aa8aa1bc7bb72b6b14c170630c5d
[jprojects-scripts.git] / pull-stick.sh
1 #!/bin/bash
2
3 . ./.jprojects.sh || exit 255
4
5 for project in ${LIST}; do
6         if [ ! -d "${JPROJECTS_HOME}/${project}" ]
7         then
8                 echo "$0: Project '${project}' does not exist."
9                 continue
10         fi
11
12         cd "${JPROJECTS_HOME}/${project}" || exit 255
13
14         if [ "$1" = "c" ]
15         then
16                 echo "$0: Checkout '${project}' ..."
17                 git checkout -- .
18         elif [ "$1" = "r" ]
19         then
20                 echo "$0: Resetting '${project}' ..."
21                 git reset --hard
22         fi
23
24         echo "$0: Pulling '${project}' ..."
25
26         git pull -S origin master
27         git pull -S upstream master
28         git pull -S transport master
29
30         if [ "$?" != "0" ]
31         then
32                 git pull --all
33         fi
34
35         echo "$0: Merging upstream into '${project}' ..."
36         git merge -S upstream/master
37
38         if [ "$1" != "s" ]
39         then
40                 echo "$0: Rebasing '${project}' ..."
41                 git rebase -Sm origin/master || exit 255
42         fi
43 done
44
45 echo "$0: All done."
46 exit 0