Catrope has uploaded a new change for review. https://gerrit.wikimedia.org/r/108189
Change subject: Script to update the oojs-ui distribution ...................................................................... Script to update the oojs-ui distribution Change-Id: I8fe8d6e4de70346873dfd457e50d01676076fa3d --- A bin/update-oojs-ui.sh A bin/update-oojs.sh 2 files changed, 164 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor refs/changes/89/108189/1 diff --git a/bin/update-oojs-ui.sh b/bin/update-oojs-ui.sh new file mode 100755 index 0000000..b874c13 --- /dev/null +++ b/bin/update-oojs-ui.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# This script generates a commit that updates the oojs-ui distribution +# ./bin/update-oojs-ui.sh path/to/oojs-ui + +function oojsuihash() { + grep "OOjs UI v" lib/oojs-ui/oojs-ui.js \ + | head -n 1 \ + | grep -Eo '\([a-z0-9]+\)' \ + | sed -r 's/\(([a-z0-9]+)\)/\1/' +} + +function oojsuitag() { + grep "OOjs UI v" lib/oojs-ui/oojs-ui.js \ + | head -n 1 \ + | grep -Eo '\bv[0-9a-z.-]+\b' +} + +function oojsuiversion() { + grep "OOjs UI v" lib/oojs-ui/oojs-ui.js \ + | head -n 1 \ + | grep -Eo '\bv[0-9a-z.-]+\b.*$' +} + +# cd to the VisualEditor directory +cd $(cd $(dirname $0)/..; pwd) + +if [ "x$1" == "x" ] +then + echo >&2 "Usage: update-oojs-ui.sh path/to/oojs-ui" + exit 1 +fi + +# Undo any changes in the oojs-ui directory +git reset lib/oojs-ui/ +git checkout lib/oojs-ui/ +# Get the old oojs-ui version +OLDVERSION=$(oojsuihash) +if [ "x$OLDVERSION" == "x" ] +then + TAG=$(oojsuitag) +fi + +# cd to the oojs-ui directory +cd $1 || exit 1 +if [ "x$OLDVERSION" == "x" ] +then + # Try the tag + OLDVERSION=$(git rev-parse $TAG) + if [ $? != 0 ] + then + echo Could not find OOJS UI version + cd - + exit 1 + fi +fi +# Build the distribution +grunt +# Get the list of changes +NEWCHANGES=$(git log $OLDVERSION.. --oneline --no-merges --reverse) +# cd back to the VisualEditor directory +cd - + +# Copy files from dist/ to lib/oojs-ui +cp -a $1/dist/* lib/oojs-ui/ +# Figure out what the new version is +NEWVERSION=$(oojsuiversion) +# Generate commit summary +COMMITMSG=$(cat <<END +Update OOjs UI to $NEWVERSION + +New changes: +$NEWCHANGES +END +) +# Commit +git commit lib/oojs-ui/ -m "$COMMITMSG" +cat >&2 <<END +Created commit with changes: +$NEWCHANGES +END \ No newline at end of file diff --git a/bin/update-oojs.sh b/bin/update-oojs.sh new file mode 100755 index 0000000..0d9d1f8 --- /dev/null +++ b/bin/update-oojs.sh @@ -0,0 +1,83 @@ +#!/usr/bin/env bash + +# FIXME this script is duplicated from update-oojs-ui.sh , factor this out + +# This script generates a commit that updates the oojs distribution +# ./bin/update-oojs.sh path/to/oojs + +function oojshash() { + grep "OOjs v" lib/oojs/oojs.js \ + | head -n 1 \ + | grep -Eo '\([a-z0-9]+\)' \ + | sed -r 's/\(([a-z0-9]+)\)/\1/' +} + +function oojstag() { + grep "OOjs v" lib/oojs/oojs.js \ + | head -n 1 \ + | grep -Eo '\bv[0-9a-z.-]+\b' +} + +function oojsversion() { + grep "OOjs v" lib/oojs/oojs.js \ + | head -n 1 \ + | grep -Eo '\bv[0-9a-z.-]+\b.*$' +} + +# cd to the VisualEditor directory +cd $(cd $(dirname $0)/..; pwd) + +if [ "x$1" == "x" ] +then + echo >&2 "Usage: update-oojs.sh path/to/oojs" + exit 1 +fi + +# Undo any changes in the oojs directory +git reset lib/oojs/ +git checkout lib/oojs/ +# Get the old oojs version +OLDVERSION=$(oojshash) +if [ "x$OLDVERSION" == "x" ] +then + TAG=$(oojstag) +fi + +# cd to the oojs directory +cd $1 || exit 1 +if [ "x$OLDVERSION" == "x" ] +then + # Try the tag + OLDVERSION=$(git rev-parse $TAG) + if [ $? != 0 ] + then + echo Could not find OOJS version + cd - + exit 1 + fi +fi +# Build the distribution +grunt +# Get the list of changes +NEWCHANGES=$(git log $OLDVERSION.. --oneline --no-merges --reverse) +# cd back to the VisualEditor directory +cd - + +# Copy files from dist/ to lib/oojs +cp -a $1/dist/* lib/oojs/ +# Figure out what the new version is +NEWVERSION=$(oojsversion) +# Generate commit summary +COMMITMSG=$(cat <<END +Update OOjs to $NEWVERSION + +New changes: +$NEWCHANGES +END +) +# Commit +git commit lib/oojs/ -m "$COMMITMSG" +cat >&2 <<END +Created commit with changes: +$NEWCHANGES +END \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/108189 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8fe8d6e4de70346873dfd457e50d01676076fa3d Gerrit-PatchSet: 1 Gerrit-Project: VisualEditor/VisualEditor Gerrit-Branch: master Gerrit-Owner: Catrope <roan.katt...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits