2015-04-28 23:45:12 +00:00
|
|
|
#!/bin/bash -eu
|
2014-01-18 00:20:12 +00:00
|
|
|
|
|
|
|
# This script generates a commit that updates the lib/ve submodule
|
|
|
|
# ./bin/updateSubmodule.sh updates to master
|
|
|
|
# ./bin/updateSubmodule.sh hash updates to specified hash
|
|
|
|
|
|
|
|
# cd to the VisualEditor directory
|
|
|
|
cd $(cd $(dirname $0)/..; pwd)
|
|
|
|
|
|
|
|
# Check that both working directories are clean
|
|
|
|
if git status -uno --ignore-submodules | grep -i changes > /dev/null
|
|
|
|
then
|
|
|
|
echo >&2 "Working directory must be clean"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd lib/ve
|
|
|
|
if git status -uno --ignore-submodules | grep -i changes > /dev/null
|
|
|
|
then
|
|
|
|
echo >&2 "lib/ve working directory must be clean"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd ../..
|
|
|
|
|
2023-11-10 18:13:04 +00:00
|
|
|
# Use 'gerrit' if it exists, otherwise 'origin'
|
|
|
|
MW_REMOTE=$(git remote | grep -w gerrit || echo origin)
|
|
|
|
|
|
|
|
git fetch $MW_REMOTE
|
2014-01-18 00:20:12 +00:00
|
|
|
# Create sync-repos branch if needed and reset it to master
|
2023-11-10 18:13:04 +00:00
|
|
|
git checkout -B sync-repos $MW_REMOTE/master
|
2014-01-18 00:20:12 +00:00
|
|
|
git submodule update
|
|
|
|
cd lib/ve
|
2023-11-10 18:13:04 +00:00
|
|
|
|
|
|
|
CORE_REMOTE=$(git remote | grep -w gerrit || echo origin)
|
|
|
|
|
|
|
|
git fetch $CORE_REMOTE
|
2014-01-18 00:20:12 +00:00
|
|
|
|
|
|
|
# Figure out what to set the submodule to
|
2015-04-29 00:13:09 +00:00
|
|
|
if [ -n "${1:-}" ]
|
2014-01-18 00:20:12 +00:00
|
|
|
then
|
|
|
|
TARGET="$1"
|
|
|
|
TARGETDESC="$1"
|
|
|
|
else
|
2023-11-10 18:13:04 +00:00
|
|
|
TARGET=$CORE_REMOTE/master
|
|
|
|
TARGETDESC="master ($(git rev-parse --short $CORE_REMOTE/master))"
|
2014-01-18 00:20:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Generate commit summary
|
|
|
|
# TODO recurse
|
2018-05-10 15:51:37 +00:00
|
|
|
NEWCHANGES=$(git log ..$TARGET --oneline --no-merges --topo-order --reverse --color=never)
|
2017-09-13 16:10:13 +00:00
|
|
|
TASKS=$(git log ..$TARGET --no-merges --format=format:%B | grep "Bug: T" | sort | uniq)
|
2023-12-08 16:51:11 +00:00
|
|
|
ADDED_I18N_KEYS=$(git diff HEAD..$TARGET -- i18n/en.json | grep '^\+' | grep --color=never -v '^\+\+\+' | sed -E 's/^\+\s*"([^"]+)":.*/\1/' | sed 's/^/- /' || :)
|
|
|
|
DELETED_I18N_KEYS=$(git diff HEAD..$TARGET -- i18n/en.json | grep '^\-' | grep --color=never -v '^\-\-\-' | sed -E 's/^\-\s*"([^"]+)":.*/\1/' | sed 's/^/- /' || :)
|
|
|
|
|
2023-12-07 17:43:22 +00:00
|
|
|
# Ensure script continues if grep "fails" (returns nothing) with || : (due to -e flag in bash)
|
2023-12-08 16:51:11 +00:00
|
|
|
ADDED_FILES=$(git diff HEAD..$TARGET --name-only --diff-filter=A | grep --color=never -E "\.(js|css|less)$" | sed 's/^/- /' || :)
|
|
|
|
DELETED_FILES=$(git diff HEAD..$TARGET --name-only --diff-filter=D | grep --color=never -E "\.(js|css|less)$" | sed 's/^/- /' || :)
|
2023-11-17 13:35:47 +00:00
|
|
|
|
|
|
|
COMMITMSG="Update VE core submodule to $TARGETDESC
|
2014-01-18 00:20:12 +00:00
|
|
|
|
|
|
|
New changes:
|
2023-11-17 13:35:47 +00:00
|
|
|
$NEWCHANGES"
|
2017-09-13 16:10:13 +00:00
|
|
|
|
2023-12-08 16:51:11 +00:00
|
|
|
if [ -n "$ADDED_I18N_KEYS" ]; then
|
|
|
|
COMMITMSG+="
|
|
|
|
|
|
|
|
Added i18n keys:
|
|
|
|
$ADDED_I18N_KEYS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$DELETED_I18N_KEYS" ]; then
|
|
|
|
COMMITMSG+="
|
|
|
|
|
|
|
|
Deleted i18n keys:
|
|
|
|
$DELETED_I18N_KEYS"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$ADDED_FILES" ]; then
|
|
|
|
COMMITMSG+="
|
2023-11-17 13:35:47 +00:00
|
|
|
|
2023-12-08 16:51:11 +00:00
|
|
|
Added files:
|
|
|
|
$ADDED_FILES"
|
2023-11-17 13:35:47 +00:00
|
|
|
fi
|
|
|
|
|
2023-12-08 16:51:11 +00:00
|
|
|
if [ -n "$DELETED_FILES" ]; then
|
|
|
|
COMMITMSG+="
|
2023-11-17 13:35:47 +00:00
|
|
|
|
2023-12-08 16:51:11 +00:00
|
|
|
Deleted files:
|
|
|
|
$DELETED_FILES"
|
2023-11-17 13:35:47 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
COMMITMSG+="
|
|
|
|
|
|
|
|
$TASKS"
|
|
|
|
|
2014-01-18 00:20:12 +00:00
|
|
|
# Check out master of VE core
|
|
|
|
git checkout $TARGET
|
|
|
|
|
|
|
|
# Commit
|
|
|
|
cd ../..
|
|
|
|
git commit lib/ve -m "$COMMITMSG" > /dev/null
|
|
|
|
if [ "$?" == "1" ]
|
|
|
|
then
|
|
|
|
echo >&2 "No changes"
|
|
|
|
else
|
|
|
|
cat >&2 <<END
|
|
|
|
|
|
|
|
|
2023-12-02 10:11:05 +00:00
|
|
|
Created commit:
|
|
|
|
|
|
|
|
$COMMITMSG
|
2014-01-18 00:20:12 +00:00
|
|
|
END
|
|
|
|
fi
|