Upload upstream chromium 94.0.4606.31
[platform/framework/web/chromium-efl.git] / third_party / wpt_tools / checkout.sh
1 #!/bin/bash
2 #
3 # Removes ./wpt/ directory containing the reduced web-platform-tests tree and
4 # starts a new checkout. Only files in WPTIncludeList are retained. The
5 # revisions getting checked out are defined in WPTHeads.
6 # TODO(weizhong): consider updating WPTIncludeList if there is new file added at
7 # upstream
8
9 DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
10 cd $DIR
11
12 TARGET_DIR=$DIR/wpt
13 REMOTE_REPO="https://github.com/web-platform-tests/wpt.git"
14 WPT_HEAD=1c62628e8bb4e8fda03a7e1af9aefbca60293381
15
16 function clone {
17   # Remove existing repo if already exists.
18   [ -d "$TARGET_DIR" ] && rm -rf $TARGET_DIR
19
20   # Clone the main repository.
21   git clone $REMOTE_REPO $TARGET_DIR
22   cd $TARGET_DIR && git checkout $WPT_HEAD
23   echo "WPTHead: " `git rev-parse HEAD`
24 }
25
26 function reduce {
27   cd $TARGET_DIR
28   # Some directories contain filenames with ' (single quote), and it confuses
29   # xargs on some platforms, so we remove those directories first.
30   rm -fr html css
31   # Remove all except white-listed.
32   comm -23 <(find . -type f -o -type l | sort) <(cat ../WPTIncludeList | sort) | xargs -d '\n' -n 1 rm
33   find . -empty -type d -delete
34 }
35
36 actions="clone reduce"
37 [ "$1" != "" ] && actions="$@"
38
39 for action in $actions; do
40   type -t $action >/dev/null || (echo "Unknown action: $action" 1>&2 && exit 1)
41   $action
42 done
43
44 # TODO(burnik): Handle the SSL certs and other configuration.