|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +echo "Syncing openvscode-server with upstream" |
| 4 | + |
| 5 | +exit_script() { |
| 6 | + reason=$1 |
| 7 | + echo "Update script ended unsucessfully" |
| 8 | + echo "Reason: $reason" |
| 9 | + exit 1 |
| 10 | +} |
| 11 | + |
| 12 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 13 | + realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; } |
| 14 | + ROOT=$(dirname $(dirname $(realpath "$0"))) |
| 15 | +else |
| 16 | + ROOT=$(dirname $(dirname $(readlink -f $0))) |
| 17 | + # --disable-dev-shm-usage --use-gl=swiftshader: when run on docker containers where size of /dev/shm |
| 18 | + # partition < 64MB which causes OOM failure for chromium compositor that uses the partition for shared memory |
| 19 | + LINUX_EXTRA_ARGS="--disable-dev-shm-usage --use-gl=swiftshader" |
| 20 | +fi |
| 21 | + |
| 22 | +cd $ROOT |
| 23 | + |
| 24 | +local_branch="web-server" |
| 25 | +upstream_url="https://github.com/microsoft/vscode.git" |
| 26 | +upstream_branch="upstream/main" |
| 27 | +base_commit_msg="code web server initial commit" |
| 28 | + |
| 29 | +# Checks is there's an upstream remote repository and if not |
| 30 | +# set it to $upstream_url |
| 31 | +check_upstream() { |
| 32 | + git remote -v | grep --quiet upstream |
| 33 | + if [[ $? -ne 0 ]]; then |
| 34 | + echo "Upstream repository not configured" |
| 35 | + echo "Setting upstream URL to ${upstream_url}" |
| 36 | + git remote add upstream $upstream_url > /dev/null |
| 37 | + fi |
| 38 | +} |
| 39 | + |
| 40 | +# Gets the base commit |
| 41 | +get_base_commit() { |
| 42 | + local base_commit=$(git log --pretty="%H" --max-count=1 --grep "$base_commit_msg") |
| 43 | + if [[ -z $base_commit ]]; then |
| 44 | + exit_script "Could not find base commit" |
| 45 | + fi |
| 46 | + echo $base_commit |
| 47 | +} |
| 48 | + |
| 49 | +# Fetch updates from upstream and rebase |
| 50 | +sync() { |
| 51 | + echo "Fetching upstream..." |
| 52 | + git fetch upstream > /dev/null |
| 53 | + git checkout --quiet $local_branch > /dev/null |
| 54 | + echo "Rebasing $local_branch branch over $upstream_branch branch from upstream" |
| 55 | + git rebase --quiet --onto=$upstream_branch $(get_base_commit)^ $local_branch |
| 56 | + if [[ $? -ne 0 ]]; then |
| 57 | + echo "There are merge conflicts doing the rebase. Reverting changes" |
| 58 | + git rebase --abort |
| 59 | + exit_script "Could not rebase succesfully" |
| 60 | + fi |
| 61 | + echo "$local_branch sucessfully updated" |
| 62 | +} |
| 63 | + |
| 64 | +# Sync |
| 65 | +check_upstream |
| 66 | +sync |
| 67 | + |
| 68 | +# Clean and build |
| 69 | +# git clean -dfx |
| 70 | +yarn && yarn server:init |
| 71 | + |
| 72 | +# Configuration |
| 73 | +export NODE_ENV=development |
| 74 | +export VSCODE_DEV=1 |
| 75 | +export VSCODE_CLI=1 |
| 76 | + |
| 77 | +yarn smoketest --web --headless --electronArgs=$LINUX_EXTRA_ARGS |
0 commit comments