-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitallextensions.sh
100 lines (92 loc) · 3.9 KB
/
gitallextensions.sh
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/bash
# @author Jack D. Pond
# @file
# @ingroup administrative
# @description Script file that adds extensions to mediawiki based on a list
# @param -f configuration file, if not present, defaults to master
# @param -b branch to be used, if not used, defaults to extensions/WikiConfig/Extensions.conf
# expects a file which contains one line per extension. Each extension can have an explicit version - but will default to the specified
# version if not present.
# @param [extension]:[Version] (lines beginning with # are considered comments)
# example
# NSFileRepo:REL1_21
# export ExtensionsAddr=ssh://[email protected]:29418/mediawiki
# export SVNExtensionsAddr=svn+ssh://[email protected]/svnroot/mediawiki/trunk
trySVN(){
echo "svn checkout \"$SVNExtensionsAddr/extensions/$1 extensions/$1\""
echo "svn checkout \"$SVNExtensionsAddr/extensions/$1 extensions/$1\"" >> "$ThisHomeDir/ExtensionLoader.log"
svn checkout "$SVNExtensionsAddr/extensions/$1" "extensions/$1"
if [ -f "extensions/$1/.svn" ]; then
echo "loaded extension $1 with SVN" >> "$ThisHomeDir/ExtensionLoader.log"
else
echo "*** Error *** Could not load extension $1"
echo "*** Error *** Could not load extension $1" >> "$ThisHomeDir/ExtensionLoader.log"
fi
}
export SVNExtensionsAddr=http://svn.wikimedia.org/svnroot/mediawiki/trunk
export ExtensionsAddr=https://gerrit.wikimedia.org/r/p/mediawiki
export ConfigFile=extensions/WikiConfig/Extensions.conf
export BranchVer=master
export ThisHomeDir=$(pwd)
echo "ThisHomeDir: $ThisHomeDir"
while getopts ":f::b:" opt; do
case $opt in
f)
export ConfigFile=$OPTARG
;;
b)
export BranchVer=$OPTARG
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ ! -f $ConfigFile ]; then
echo "Media Extension File List $ConfigFile does not exist - exiting"
exit 1
fi
echo "Starting MediaWiki Extension Loader from $ConfigFile at $(hostname) $(date)" > "$ThisHomeDir/ExtensionLoader.log"
while read line; do
if [ "${line:0:1}" != "#" ] ; then
export _extension=`echo $line | cut -d: -f1`
export _version=`echo $line | cut -s -d: -f2`
[ "$_version" == "" ] && export _version=$BranchVer
echo "Processing Extension: $_extension"
if [ -d "extensions/$_extension/.git" ]; then
pushd "extensions/$_extension"
git checkout $_version
popd
else
git clone -n "$ExtensionsAddr/extensions/$_extension.git" "extensions/$_extension" >> "$ThisHomeDir/ExtensionLoader.log"
if [ -d extensions/$_extension/.git ];then
pushd "extensions/$_extension"
echo "git checkout -b $_version origin/$_version"
echo "git checkout -b $_version origin/$_version" >> "$ThisHomeDir/ExtensionLoader.log"
git checkout -b "$_version" "origin/$_version" >> "$ThisHomeDir/ExtensionLoader.log"
popd
echo "Adding Submodule $_extension"
echo "Adding Submodule $_extension" >> "$ThisHomeDir/ExtensionLoader.log"
echo "git submodule add -f \"$ExtensionsAddr/extensions/$_extension.git\" \"extensions/$_extension\""
echo "git submodule add -f \"$ExtensionsAddr/extensions/$_extension.git\" \"extensions/$_extension\"" >> "$ThisHomeDir/ExtensionLoader.log"
git submodule add --force "$ExtensionsAddr/extensions/$_extension.git" "extensions/$_extension" >> "$ThisHomeDir/ExtensionLoader.log"
# only valid if using ssh
# pushd "extensions/$_extension"
# git-review -s -r origin
# popd
fi
fi
if [ ! -d "extensions/$_extension/.git" ]; then
mkdir extensions/$_extension
echo "**** $_extension is not in git **** trying svn"
echo "**** $_extension is not in git **** trying svn" >> "$ThisHomeDir/ExtensionLoader.log"
trySVN "$_extension" $_version
fi
fi
done < $ConfigFile
exit 0