summaryrefslogtreecommitdiff
path: root/maintenance/resources
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-12-27 15:41:37 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-12-31 11:43:28 +0100
commitc1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch)
tree2b38796e738dd74cb42ecd9bfd151803108386bc /maintenance/resources
parentb88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff)
Update to MediaWiki 1.24.1
Diffstat (limited to 'maintenance/resources')
-rw-r--r--maintenance/resources/update-oojs-ui.sh95
-rw-r--r--maintenance/resources/update-oojs.sh53
2 files changed, 148 insertions, 0 deletions
diff --git a/maintenance/resources/update-oojs-ui.sh b/maintenance/resources/update-oojs-ui.sh
new file mode 100644
index 00000000..1b352922
--- /dev/null
+++ b/maintenance/resources/update-oojs-ui.sh
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+
+# This script generates a commit that updates our distribution copy of OOjs UI
+
+if [ -z "$1" ]
+then
+ # Missing required parameter
+ echo >&2 "Usage: $0 path/to/repo/for/oojs-ui"
+ exit 1
+fi
+
+TARGET_REPO=$(cd "$(dirname $0)/../.."; pwd)
+TARGET_DIR=resources/lib/oojs-ui
+UI_REPO=$1
+
+function oojsuihash() {
+ grep "OOjs UI v" "$TARGET_REPO/$TARGET_DIR/oojs-ui.js" \
+ | head -n 1 \
+ | grep -Eo '\([a-z0-9]+\)' \
+ | sed 's/^(//' \
+ | sed 's/)$//'
+}
+
+function oojsuitag() {
+ grep "OOjs UI v" "$TARGET_REPO/$TARGET_DIR/oojs-ui.js" \
+ | head -n 1 \
+ | grep -Eo '\bv[0-9a-z.-]+\b'
+}
+
+function oojsuiversion() {
+ grep "OOjs UI v" "$TARGET_REPO/$TARGET_DIR/oojs-ui.js" \
+ | head -n 1 \
+ | grep -Eo '\bv[0-9a-z.-]+\b.*$'
+}
+
+# Prepare working tree
+cd "$TARGET_REPO" &&
+git reset $TARGET_DIR && git checkout $TARGET_DIR && git fetch origin &&
+git checkout -B upstream-oojsui origin/master || exit 1
+
+cd $UI_REPO || exit 1
+
+# Read the old version and check for changes
+OLDHASH=$(oojsuihash)
+if [ -z "$OLDHASH" ]
+then
+ OLDTAG=$(oojsuitag)
+fi
+if [ "$OLDHASH" == "" ]
+then
+ OLDHASH=$(git rev-parse "$OLDTAG")
+ if [ $? != 0 ]
+ then
+ echo "Could not find OOjs UI version"
+ cd -
+ exit 1
+ fi
+fi
+if [ "$(git rev-parse $OLDHASH)" == "$(git rev-parse HEAD)" ]
+then
+ echo "No changes (already at $OLDHASH)"
+ cd -
+ exit 0
+fi
+
+# Build the distribution
+npm install && grunt git-build || exit 1
+
+# Get the list of changes
+NEWCHANGES=$(git log $OLDHASH.. --oneline --no-merges --reverse --color=never)
+NEWCHANGESDISPLAY=$(git log $OLDHASH.. --oneline --no-merges --reverse --color=always)
+
+# Copy files
+# - Exclude the default non-svg stylesheet
+rsync --recursive --delete --force --exclude 'oojs-ui.css' --exclude 'oojs-ui*.rtl.css' ./dist/ "$TARGET_REPO/$TARGET_DIR" || exit 1
+
+# Read the new version
+NEWVERSION=$(oojsuiversion)
+
+# Generate commit
+cd "$TARGET_REPO"
+COMMITMSG=$(cat <<END
+Update OOjs UI to $NEWVERSION
+
+New changes:
+$NEWCHANGES
+END
+)
+git add -u $TARGET_DIR && git add $TARGET_DIR && git commit -m "$COMMITMSG"
+cat >&2 <<END
+
+
+Created commit with changes:
+$NEWCHANGESDISPLAY
+END
diff --git a/maintenance/resources/update-oojs.sh b/maintenance/resources/update-oojs.sh
new file mode 100644
index 00000000..d9e6fb9d
--- /dev/null
+++ b/maintenance/resources/update-oojs.sh
@@ -0,0 +1,53 @@
+#!/usr/bin/env bash
+
+if [ -n "$2" ]
+then
+ # Too many parameters
+ echo >&2 "Usage: $0 [<version>]"
+ exit 1
+fi
+
+REPO_DIR=$(cd "$(dirname $0)/../.."; pwd) # Root dir of the git repo working tree
+TARGET_DIR="resources/lib/oojs" # Destination relative to the root of the repo
+NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-oojs') # e.g. /tmp/update-oojs.rI0I5Vir
+
+# Prepare working tree
+cd "$REPO_DIR" &&
+git reset $TARGET_DIR && git checkout $TARGET_DIR && git fetch origin &&
+git checkout -B upstream-oojs origin/master || exit 1
+
+# Fetch upstream version
+cd $NPM_DIR
+if [ -n "$1" ]
+then
+ npm install "oojs@$1" || exit 1
+else
+ npm install oojs || exit 1
+fi
+
+OOJS_VERSION=$(node -e 'console.log(JSON.parse(require("fs").readFileSync("./node_modules/oojs/package.json")).version);')
+if [ "$OOJS_VERSION" == "" ]
+then
+ echo 'Could not find OOjs version'
+ exit 1
+fi
+
+# Copy file(s)
+rsync --force ./node_modules/oojs/dist/oojs.jquery.js "$REPO_DIR/$TARGET_DIR" || exit 1
+
+# Clean up temporary area
+rm -rf "$NPM_DIR"
+
+# Generate commit
+cd $REPO_DIR || exit 1
+
+COMMITMSG=$(cat <<END
+Update OOjs to v$OOJS_VERSION
+
+Release notes:
+ https://git.wikimedia.org/blob/oojs%2Fcore.git/v$OOJS_VERSION/History.md
+END
+)
+
+# Stage deletion, modification and creation of files. Then commit.
+git add --update $TARGET_DIR && git add $TARGET_DIR && git commit -m "$COMMITMSG" || exit 1