Some fixes:
[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 [ -n "$2" ]
15         then
16                 git branch -D "$2"
17         fi
18
19         if [ "$1" = "c" ]
20         then
21                 echo "$0: Checkout '${project}' ..."
22                 git checkout -- .
23         elif [ "$1" = "r" ]
24         then
25                 echo "$0: Resetting '${project}' ..."
26                 git reset --hard
27         fi
28
29         echo "$0: Pulling '${project}' ..."
30
31         git pull -S origin master
32         git pull -S upstream master
33         git pull -S transport master
34
35         if [ "$?" != "0" ]
36         then
37                 git pull --all
38         fi
39
40         echo "$0: Merging upstream into '${project}' ..."
41         git merge -S upstream/master
42
43         if [ "$1" != "s" ]
44         then
45                 echo "$0: Rebasing '${project}' ..."
46                 git rebase -Sm origin/master || exit 255
47         fi
48 done
49
50 echo "$0: All done."
51 exit 0