-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdevup
executable file
·150 lines (118 loc) · 2.93 KB
/
devup
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
#
# This is a small script to update a set of svn and git repositories in one go
#
# Author: Stefan Hepp <hepp@complang.tuwien.ac.at>
#
# TODO alternatively check home for devup.cfg?
self=`readlink -f $0`
cfgfile=`dirname $self`/devup.cfg
base=`dirname $self`/..
##### Configuration starts here. Overwrite defaults in ./devup.cfg #####
#
# By default assume that all other repositories are checked out into the parent
# directory of this folder. Set repository names and the git and svn base dirs
# in 'devup.cfg' in the same folder as this script to your setup if you have a
# different directory layout.
#
# Base directory for git and svn repositories
GITBASE=$base
SVNBASE=$base
# Names of svn subdirectories in $SVNBASE
SVNREPOS="tcrest tcapapers"
# Names of git subdirectories in $GITBASE
GITREPOS="patmos benchmarks newlib compiler-rt gold clang llvm misc"
# Perform git stash before updating
DO_STASH=false
# Color codes
RED="\033[31m"
NOCOLOR="\033[0m"
##### Configuration ends here #####
if [ -f $cfgfile ]; then
. $cfgfile
fi
function usage() {
echo "Usage: $0 [-s] [<repostype> ..] "
echo
echo " -s Use git stash before updating git"
echo
echo "Repository types can be 'git' or 'svn'. Will update all types if omitted."
echo
}
function gitup() {
repo=$1
if [ ! -d $GITBASE/$repo ]; then
return
fi
echo -e "* Updating$RED $repo" $NOCOLOR
pushd $GITBASE/$repo > /dev/null
if [ "$DO_STASH" == "true" ]; then
ret=$(git stash)
if [ "$?" != "0" ]; then
echo "git stash failed!"
exit 1
fi
# TODO is there a better way of doing this?
local skip_stash=false
if [ "$ret" == "No local changes to save" ]; then
skip_stash=true
fi
fi
# ignore errors of pull ..
(git pull --rebase; git status -uno) | while read a; do
if [ "$a" == "Current branch master is up to date." ]; then
continue
fi
if [ "$a" == "# On branch master" ]; then
continue
fi
if [ "$a" == "nothing to commit (use -u to show untracked files)" ]; then
continue
fi
echo $a
done
if [ "$DO_STASH" == "true" -a "$skip_stash" != "true" ]; then
# continue on error ..
git stash pop
fi
popd > /dev/null
echo
}
function svnup() {
repo=$1
if [ ! -d $SVNBASE/$repo ]; then
return
fi
echo -e "* Updating$RED $repo" $NOCOLOR
svn up $SVNBASE/$repo
echo
}
DO_UPDATE_ALL=true
DO_UPDATE_GIT=false
DO_UPDATE_SVN=false
while [ ! -z "$1" ]; do
case $1 in
git) DO_UPDATE_ALL=false; DO_UPDATE_GIT=true ;;
svn) DO_UPDATE_ALL=false; DO_UPDATE_SVN=true ;;
-s) DO_STASH=true ;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
shift
done
if [ "$DO_UPDATE_GIT" == "true" -o "$DO_UPDATE_ALL" == "true" ]; then
for repo in $GITREPOS; do
gitup $repo
done
fi
if [ "$DO_UPDATE_SVN" == "true" -o "$DO_UPDATE_ALL" == "true" ]; then
for repo in $SVNREPOS; do
svnup $repo
done
fi