-
Notifications
You must be signed in to change notification settings - Fork 10
/
git-update-me
executable file
·100 lines (82 loc) · 2.17 KB
/
git-update-me
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
#!/bin/sh
#
# Copyright (c) 2010 Texas Instruments
#
# Author: Nicolas Dechesne <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
#
######################################################################
usage()
{
echo "usage: $(basename $0) -c <config>"
cat <<EOF
This script will update all git trees that are specified in the configuration
file. For each git tree to update, the script simply fetches all new objects, and prunes
old objects.
Required options:
-c <file> : This is the configuration file. The file format is simple:
- it's a text file
- each line has a absolute path to the root of a git tree to update
- e.g. /var/www/repo/linux/kernel.git
Other options:
-h, --help : Display this help message
-v : Verbose mode (set -x)
-n : Print only
EOF
exit 0
}
checkparm()
{
if [ "$(echo $1|grep ^'\-')" ];then
echo "E: Need an argument"
usage
fi
}
ECHO=
# parse commandline options
while [ ! -z "$1" ]; do
case $1 in
-h|--help)
usage
;;
-v)
set -x
;;
-n)
ECHO=echo
;;
-c)
checkparm $2
CONFIGFILE="$2"
;;
esac
shift
done
# used this to manage the 'print only' version
GIT="$ECHO git"
CD="$ECHO cd"
if [ ! "${CONFIGFILE}" ] ;then
usage
fi
echo Starting at `date`
for ii in `cat $CONFIGFILE` ; do
echo Updating $ii
$CD $ii
$GIT fetch
$GIT remote prune origin
done
echo Completed at `date`