Merge "Ticking 'Search in all namespaces' in prefs should disable other checkboxes"
[lhc/web/wiklou.git] / resources / oojs / update-oojs.sh
1 #!/usr/bin/env bash
2
3 # FIXME this script is duplicated from update-oojs-ui.sh - factor this out
4
5 # This script generates a commit that updates the oojs distribution
6 # ./bin/update-oojs.sh path/to/repo/for/oojs
7
8 function oojshash() {
9 grep "OOjs v" resources/oojs/oojs.js \
10 | head -n 1 \
11 | grep -Eo '\([a-z0-9]+\)' \
12 | sed 's/^(//' \
13 | sed 's/)$//'
14 }
15
16 function oojstag() {
17 grep "OOjs v" resources/oojs/oojs.js \
18 | head -n 1 \
19 | grep -Eo '\bv[0-9a-z.-]+\b'
20 }
21
22 function oojsversion() {
23 grep "OOjs v" resources/oojs/oojs.js \
24 | head -n 1 \
25 | grep -Eo '\bv[0-9a-z.-]+\b.*$'
26 }
27
28 # cd to the MW directory
29 cd $(cd $(dirname $0)/../..; pwd)
30
31 if [ "x$1" == "x" ]
32 then
33 echo >&2 "Usage: update-oojs.sh path/to/repo/for/oojs"
34 exit 1
35 fi
36
37 # Undo any changes in the oojs directory
38 git reset resources/oojs/
39 git checkout resources/oojs/
40 # Get the old oojs version
41 OLDVERSION=$(oojshash)
42 if [ "x$OLDVERSION" == "x" ]
43 then
44 TAG=$(oojstag)
45 fi
46
47 # cd to the oojs directory
48 cd $1 || exit 1
49 if [ "x$OLDVERSION" == "x" ]
50 then
51 # Try the tag
52 OLDVERSION=$(git rev-parse $TAG)
53 if [ $? != 0 ]
54 then
55 echo Could not find OOjs version
56 cd -
57 exit 1
58 fi
59 fi
60 if [ "$(git rev-parse $OLDVERSION)" == "$(git rev-parse HEAD)" ]
61 then
62 echo "No changes (already at $OLDVERSION)"
63 cd -
64 exit 0
65 fi
66 # Build the distribution
67 grunt
68 # Get the list of changes
69 NEWCHANGES=$(git log $OLDVERSION.. --oneline --no-merges --reverse --color=never)
70 NEWCHANGESDISPLAY=$(git log $OLDVERSION.. --oneline --no-merges --reverse --color=always)
71 # cd back to the VisualEditor directory
72 cd -
73
74 # Copy files from dist/ to resources/oojs/
75 cp -a $1/dist/* resources/oojs/
76 # Figure out what the new version is
77 NEWVERSION=$(oojsversion)
78 # Generate commit summary
79 COMMITMSG=$(cat <<END
80 Update OOjs to $NEWVERSION
81
82 New changes:
83 $NEWCHANGES
84 END
85 )
86 # Commit
87 git commit resources/oojs/ -m "$COMMITMSG"
88 cat >&2 <<END
89
90
91 Created commit with changes:
92 $NEWCHANGESDISPLAY
93 END