3 # This script generates a commit that updates our distribution copy of OOjs UI
7 # Missing required parameter
8 echo >&2 "Usage: $0 path/to/repo/for/oojs-ui"
12 TARGET_REPO
=$
(cd $
(dirname $0)/..
/..
; pwd)
13 TARGET_DIR
=resources
/lib
/oojs-ui
16 function oojsuihash
() {
17 grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
19 |
grep -Eo '\([a-z0-9]+\)' \
24 function oojsuitag
() {
25 grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
27 |
grep -Eo '\bv[0-9a-z.-]+\b'
30 function oojsuiversion
() {
31 grep "OOjs UI v" $TARGET_REPO/$TARGET_DIR/oojs-ui.js \
33 |
grep -Eo '\bv[0-9a-z.-]+\b.*$'
36 # Prepare working tree
38 git
reset $TARGET_DIR && git checkout
$TARGET_DIR && git fetch origin
&&
39 git checkout
-B upstream-oojsui origin
/master ||
exit 1
43 # Read the old version and check for changes
49 if [ "$OLDHASH" == "" ]
51 OLDHASH
=$
(git rev-parse
$OLDTAG)
54 echo Could not
find OOjs UI version
59 if [ "$(git rev-parse $OLDHASH)" == "$(git rev-parse HEAD)" ]
61 echo "No changes (already at $OLDHASH)"
66 # Build the distribution (using grunt-test instead of grunt-build, because we
67 # want to run unit tests first, and because grunt-build is for a release build
68 # and wouldn't put a git hash in the file headers)
69 npm
install && grunt
test ||
exit 1
71 # Get the list of changes
72 NEWCHANGES
=$
(git log
$OLDHASH..
--oneline --no-merges --reverse --color=never
)
73 NEWCHANGESDISPLAY
=$
(git log
$OLDHASH..
--oneline --no-merges --reverse --color=always
)
76 # - Exclude the default non-svg stylesheet
77 rsync
--recursive --delete --force --exclude 'oojs-ui.css' .
/dist
/ $TARGET_REPO/$TARGET_DIR ||
exit 1
79 # Read the new version
80 NEWVERSION
=$
(oojsuiversion
)
85 Update OOjs UI to $NEWVERSION
91 git add
-u $TARGET_DIR && git add
$TARGET_DIR && git commit
-m "$COMMITMSG"
95 Created commit with changes: