SessionManager: Save user name to metadata even if the user doesn't exist locally
[mediawiki.git] / maintenance / resources / update-oojs.sh
blobb91cb2816b787c021073df98c11fceaf66849d14
1 #!/bin/bash -eu
3 # This script generates a commit that updates our copy of OOjs
5 if [ -n "${2:-}" ]
6 then
7 # Too many parameters
8 echo >&2 "Usage: $0 [<version>]"
9 exit 1
12 REPO_DIR=$(cd "$(dirname $0)/../.."; pwd) # Root dir of the git repo working tree
13 TARGET_DIR="resources/lib/oojs" # Destination relative to the root of the repo
14 NPM_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'update-oojs') # e.g. /tmp/update-oojs.rI0I5Vir
16 # Prepare working tree
17 cd "$REPO_DIR"
18 git reset -- $TARGET_DIR
19 git checkout -- $TARGET_DIR
20 git fetch origin
21 git checkout -B upstream-oojs origin/master
23 # Fetch upstream version
24 cd $NPM_DIR
25 if [ -n "${1:-}" ]
26 then
27 npm install "oojs@$1"
28 else
29 npm install oojs
32 OOJS_VERSION=$(node -e 'console.log(require("./node_modules/oojs/package.json").version);')
33 if [ "$OOJS_VERSION" == "" ]
34 then
35 echo 'Could not find OOjs version'
36 exit 1
39 # Copy file(s)
40 rsync --force ./node_modules/oojs/dist/oojs.jquery.js "$REPO_DIR/$TARGET_DIR"
42 # Clean up temporary area
43 rm -rf "$NPM_DIR"
45 # Generate commit
46 cd $REPO_DIR
48 COMMITMSG=$(cat <<END
49 Update OOjs to v$OOJS_VERSION
51 Release notes:
52 https://git.wikimedia.org/blob/oojs%2Fcore.git/v$OOJS_VERSION/History.md
53 END
56 # Stage deletion, modification and creation of files. Then commit.
57 git add --update $TARGET_DIR
58 git add $TARGET_DIR
59 git commit -m "$COMMITMSG"