2017-05-17 20:21:58 +03:00
|
|
|
#!/bin/bash
|
2017-05-17 18:11:34 +03:00
|
|
|
|
|
|
|
# Fetches the js-sdk and matrix-react-sdk dependencies for development
|
|
|
|
# or testing purposes
|
|
|
|
# If there exists a branch of that dependency with the same name as
|
|
|
|
# the branch the current checkout is on, use that branch. Otherwise,
|
|
|
|
# use develop.
|
|
|
|
|
2017-05-31 17:37:30 +03:00
|
|
|
set -e
|
|
|
|
|
2017-06-01 20:02:51 +03:00
|
|
|
GIT_CLONE_ARGS=("$@")
|
2019-01-23 06:28:09 +03:00
|
|
|
[ -z "$defbranch" ] && defbranch="develop"
|
2017-05-17 18:11:34 +03:00
|
|
|
|
2017-06-01 20:02:51 +03:00
|
|
|
# clone a specific branch of a github repo
|
|
|
|
function clone() {
|
|
|
|
org=$1
|
|
|
|
repo=$2
|
|
|
|
branch=$3
|
2019-01-23 06:28:09 +03:00
|
|
|
|
|
|
|
# Chop 'origin' off the start as jenkins ends up using
|
|
|
|
# branches on the origin, but this doesn't work if we
|
|
|
|
# specify the branch when cloning.
|
|
|
|
branch=${branch#origin/}
|
|
|
|
|
|
|
|
if [ -n "$branch" ]
|
|
|
|
then
|
|
|
|
echo "Trying to use $org/$repo#$branch"
|
|
|
|
git clone https://github.com/$org/$repo.git $repo --branch $branch \
|
|
|
|
"${GIT_CLONE_ARGS[@]}"
|
2019-01-23 14:40:21 +03:00
|
|
|
return $?
|
2019-01-23 06:28:09 +03:00
|
|
|
fi
|
2019-01-23 14:40:21 +03:00
|
|
|
return 1
|
2017-06-01 20:02:51 +03:00
|
|
|
}
|
|
|
|
|
2017-05-17 18:11:34 +03:00
|
|
|
function dodep() {
|
|
|
|
org=$1
|
|
|
|
repo=$2
|
2017-06-01 20:02:51 +03:00
|
|
|
rm -rf $repo
|
2019-01-23 06:28:09 +03:00
|
|
|
|
|
|
|
# Try the PR author's branch in case it exists on the deps as well.
|
|
|
|
# Try the target branch of the push or PR.
|
|
|
|
# Use the default branch as the last resort.
|
|
|
|
if [[ "$TRAVIS" == true ]]; then
|
|
|
|
clone $org $repo $TRAVIS_PULL_REQUEST_BRANCH ||
|
|
|
|
clone $org $repo $TRAVIS_BRANCH ||
|
|
|
|
clone $org $repo $defbranch ||
|
|
|
|
return $?
|
|
|
|
else
|
|
|
|
clone $org $repo $ghprbSourceBranch ||
|
|
|
|
clone $org $repo $GIT_BRANCH ||
|
|
|
|
clone $org $repo `git rev-parse --abbrev-ref HEAD` ||
|
|
|
|
clone $org $repo $defbranch ||
|
|
|
|
return $?
|
|
|
|
fi
|
2017-06-01 20:02:51 +03:00
|
|
|
|
2017-08-08 11:43:40 +03:00
|
|
|
echo "$repo set to branch "`git -C "$repo" rev-parse --abbrev-ref HEAD`
|
2017-06-01 20:02:51 +03:00
|
|
|
|
|
|
|
mkdir -p node_modules
|
2018-09-18 02:57:27 +03:00
|
|
|
npm link "./$repo" # This does an npm install for us
|
2017-05-17 18:11:34 +03:00
|
|
|
}
|
|
|
|
|
2017-08-08 11:43:40 +03:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 20:02:51 +03:00
|
|
|
echo -en 'travis_fold:start:matrix-js-sdk\r'
|
|
|
|
echo 'Setting up matrix-js-sdk'
|
|
|
|
|
2017-05-17 18:11:34 +03:00
|
|
|
dodep matrix-org matrix-js-sdk
|
2017-06-01 20:02:51 +03:00
|
|
|
|
|
|
|
echo -en 'travis_fold:end:matrix-js-sdk\r'
|
|
|
|
|
2017-08-08 11:43:40 +03:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 20:02:51 +03:00
|
|
|
echo -en 'travis_fold:start:matrix-react-sdk\r'
|
|
|
|
echo 'Setting up matrix-react-sdk'
|
|
|
|
|
2017-05-17 18:11:34 +03:00
|
|
|
dodep matrix-org matrix-react-sdk
|
2017-05-17 20:14:28 +03:00
|
|
|
|
2018-09-18 02:46:13 +03:00
|
|
|
# replace the version of js-sdk that got pulled into react-sdk with a link
|
2017-08-08 11:43:40 +03:00
|
|
|
# to our version. Make sure to do this *after* doing 'npm i' in react-sdk,
|
|
|
|
# otherwise npm helpfully moves another-json from matrix-js-sdk/node_modules
|
|
|
|
# into matrix-react-sdk/node_modules.
|
|
|
|
#
|
|
|
|
# (note this matches the instructions in the README.)
|
2018-09-18 02:46:13 +03:00
|
|
|
cd matrix-react-sdk
|
|
|
|
npm link ../matrix-js-sdk
|
|
|
|
cd ../
|
2017-06-01 20:02:51 +03:00
|
|
|
|
|
|
|
echo -en 'travis_fold:end:matrix-react-sdk\r'
|
|
|
|
|
2017-08-08 11:43:40 +03:00
|
|
|
##############################
|
|
|
|
|
2017-05-17 20:14:28 +03:00
|
|
|
# Link the reskindex binary in place: if we used npm link,
|
|
|
|
# npm would do this for us, but we don't because we'd have
|
|
|
|
# to define the npm prefix somewhere so it could put the
|
|
|
|
# intermediate symlinks there. Instead, we do it ourselves.
|
2017-06-01 20:02:51 +03:00
|
|
|
mkdir -p node_modules/.bin
|
|
|
|
ln -sfv ../matrix-react-sdk/scripts/reskindex.js node_modules/.bin/reskindex
|