2019-11-19 05:18:28 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
2019-11-20 03:08:27 +03:00
|
|
|
trap "cd $(pwd -P)" EXIT
|
2019-11-19 05:18:28 +03:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2019-11-22 04:06:57 +03:00
|
|
|
REMOTE_BROWSER_UPSTREAM="browser_upstream"
|
|
|
|
BUILD_BRANCH="playwright-build"
|
|
|
|
|
2019-12-10 00:16:27 +03:00
|
|
|
# COLORS
|
|
|
|
RED=$'\e[1;31m'
|
|
|
|
GRN=$'\e[1;32m'
|
|
|
|
YEL=$'\e[1;33m'
|
|
|
|
END=$'\e[0m'
|
|
|
|
|
2019-11-19 05:18:28 +03:00
|
|
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
|
|
|
echo "usage: export.sh [firefox|webkit] [custom_checkout_path]"
|
|
|
|
echo
|
2019-11-22 04:06:57 +03:00
|
|
|
echo "Exports patch from the current branch of the checkout to browser folder."
|
|
|
|
echo "The checkout has to be 'prepared', meaning that 'prepare_checkout.sh' should be"
|
|
|
|
echo "run against it first."
|
2019-11-19 05:18:28 +03:00
|
|
|
echo
|
|
|
|
echo "You can optionally specify custom_checkout_path if you have browser checkout somewhere else"
|
|
|
|
echo "and wish to export patches from it."
|
|
|
|
echo
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $# == 0 ]]; then
|
|
|
|
echo "missing browser: 'firefox' or 'webkit'"
|
|
|
|
echo "try './export.sh --help' for more information"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# FRIENDLY_CHECKOUT_PATH is used only for logging.
|
|
|
|
FRIENDLY_CHECKOUT_PATH="";
|
|
|
|
CHECKOUT_PATH=""
|
|
|
|
EXPORT_PATH=""
|
2020-03-24 23:22:46 +03:00
|
|
|
if [[ ("$1" == "firefox") || ("$1" == "firefox/") || ("$1" == "ff") ]]; then
|
2019-11-19 05:18:28 +03:00
|
|
|
FRIENDLY_CHECKOUT_PATH="//browser_patches/firefox/checkout";
|
|
|
|
CHECKOUT_PATH="$PWD/firefox/checkout"
|
|
|
|
EXPORT_PATH="$PWD/firefox/"
|
2019-11-22 04:06:57 +03:00
|
|
|
source "./firefox/UPSTREAM_CONFIG.sh"
|
2020-03-24 23:22:46 +03:00
|
|
|
elif [[ ("$1" == "webkit") || ("$1" == "webkit/") || ("$1" == "wk") ]]; then
|
2019-11-19 05:18:28 +03:00
|
|
|
FRIENDLY_CHECKOUT_PATH="//browser_patches/webkit/checkout";
|
|
|
|
CHECKOUT_PATH="$PWD/webkit/checkout"
|
|
|
|
EXPORT_PATH="$PWD/webkit/"
|
2019-11-22 04:06:57 +03:00
|
|
|
source "./webkit/UPSTREAM_CONFIG.sh"
|
2019-11-19 05:18:28 +03:00
|
|
|
else
|
|
|
|
echo ERROR: unknown browser to export - "$1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# we will use this just for beauty.
|
|
|
|
if [[ $# == 2 ]]; then
|
2019-12-03 21:47:49 +03:00
|
|
|
echo "WARNING: using custom checkout path $2"
|
2019-11-19 05:18:28 +03:00
|
|
|
CHECKOUT_PATH=$2
|
2019-12-03 21:47:49 +03:00
|
|
|
FRIENDLY_CHECKOUT_PATH="<custom_checkout ( $2 )>"
|
2019-11-19 05:18:28 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
# if there's no checkout folder - bail out.
|
|
|
|
if ! [[ -d $CHECKOUT_PATH ]]; then
|
|
|
|
echo "ERROR: $FRIENDLY_CHECKOUT_PATH is missing - nothing to export."
|
|
|
|
exit 1;
|
|
|
|
else
|
|
|
|
echo "-- checking $FRIENDLY_CHECKOUT_PATH exists - OK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# if folder exists but not a git repository - bail out.
|
|
|
|
if ! [[ -d $CHECKOUT_PATH/.git ]]; then
|
|
|
|
echo "ERROR: $FRIENDLY_CHECKOUT_PATH is not a git repository! Nothing to export."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "-- checking $FRIENDLY_CHECKOUT_PATH is a git repo - OK"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Switch to git repository.
|
|
|
|
cd $CHECKOUT_PATH
|
|
|
|
|
2019-11-22 04:06:57 +03:00
|
|
|
# Setting up |$REMOTE_BROWSER_UPSTREAM| remote and fetch the $BASE_BRANCH
|
|
|
|
if git remote get-url $REMOTE_BROWSER_UPSTREAM >/dev/null; then
|
2019-12-10 00:54:38 +03:00
|
|
|
if ! [[ $(git config --get remote.$REMOTE_BROWSER_UPSTREAM.url || echo "") == "$REMOTE_URL" ]]; then
|
|
|
|
echo "ERROR: remote $REMOTE_BROWSER_UPSTREAM is not pointing to '$REMOTE_URL'! run `prepare_checkout.sh` first"
|
|
|
|
exit 1
|
2019-11-22 04:06:57 +03:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "ERROR: checkout does not have $REMOTE_BROWSER_UPSTREAM; run `prepare_checkout.sh` first"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-19 05:18:28 +03:00
|
|
|
# Check if git repo is dirty.
|
2019-12-03 21:47:49 +03:00
|
|
|
if [[ -n $(git status -s --untracked-files=no) ]]; then
|
2019-11-19 05:18:28 +03:00
|
|
|
echo "ERROR: $FRIENDLY_CHECKOUT_PATH has dirty GIT state - aborting export."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "-- checking $FRIENDLY_CHECKOUT_PATH is clean - OK"
|
|
|
|
fi
|
|
|
|
|
2019-12-14 04:25:33 +03:00
|
|
|
git fetch $REMOTE_BROWSER_UPSTREAM $BASE_BRANCH
|
|
|
|
|
2019-12-10 00:16:27 +03:00
|
|
|
PATCH_NAME=$(ls -1 $EXPORT_PATH/patches)
|
|
|
|
if [[ -z "$PATCH_NAME" ]]; then
|
|
|
|
PATCH_NAME="bootstrap.diff"
|
|
|
|
OLD_DIFF=""
|
2019-11-23 06:18:52 +03:00
|
|
|
else
|
2019-12-10 00:16:27 +03:00
|
|
|
OLD_DIFF=$(cat $EXPORT_PATH/patches/$PATCH_NAME)
|
2019-11-23 06:18:52 +03:00
|
|
|
fi
|
|
|
|
|
2019-12-10 00:16:27 +03:00
|
|
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
|
|
|
NEW_BASE_REVISION=$(git merge-base $REMOTE_BROWSER_UPSTREAM/$BASE_BRANCH $CURRENT_BRANCH)
|
2019-12-17 03:17:56 +03:00
|
|
|
NEW_DIFF=$(git diff --full-index $NEW_BASE_REVISION $CURRENT_BRANCH)
|
2019-12-10 00:16:27 +03:00
|
|
|
# Increment BUILD_NUMBER
|
|
|
|
BUILD_NUMBER=$(cat $EXPORT_PATH/BUILD_NUMBER)
|
|
|
|
BUILD_NUMBER=$((BUILD_NUMBER+1))
|
|
|
|
if [[ "$NEW_BASE_REVISION" == "$BASE_REVISION" && "$OLD_DIFF" == "$NEW_DIFF" ]]; then
|
|
|
|
echo "No changes"
|
2019-11-23 06:18:52 +03:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-11-22 04:06:57 +03:00
|
|
|
echo "REMOTE_URL=\"$REMOTE_URL\"
|
|
|
|
BASE_BRANCH=\"$BASE_BRANCH\"
|
2019-11-23 06:18:52 +03:00
|
|
|
BASE_REVISION=\"$NEW_BASE_REVISION\"" > $EXPORT_PATH/UPSTREAM_CONFIG.sh
|
2019-12-10 00:16:27 +03:00
|
|
|
echo "$NEW_DIFF" > $EXPORT_PATH/patches/$PATCH_NAME
|
2019-11-19 05:18:28 +03:00
|
|
|
echo $BUILD_NUMBER > $EXPORT_PATH/BUILD_NUMBER
|
2019-12-10 00:16:27 +03:00
|
|
|
|
|
|
|
NEW_BASE_REVISION_TEXT="$NEW_BASE_REVISION (not changed)"
|
|
|
|
if [[ "$NEW_BASE_REVISION" != "$BASE_REVISION" ]]; then
|
|
|
|
NEW_BASE_REVISION_TEXT="$YEL$NEW_BASE_REVISION (changed)$END"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "=============================================================="
|
|
|
|
echo " Repository: $FRIENDLY_CHECKOUT_PATH"
|
|
|
|
echo " Changes between branches: $REMOTE_BROWSER_UPSTREAM/$BASE_BRANCH..$CURRENT_BRANCH"
|
|
|
|
echo " BASE_REVISION: $NEW_BASE_REVISION_TEXT"
|
|
|
|
echo " BUILD_NUMBER: $YEL$BUILD_NUMBER (changed)$END"
|
|
|
|
echo "=============================================================="
|
|
|
|
echo
|