2017-05-17 17:21:58 +00:00
|
|
|
#!/bin/bash
|
2017-05-17 15:11:34 +00: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 14:37:30 +00:00
|
|
|
set -e
|
|
|
|
|
2017-06-01 17:02:51 +00:00
|
|
|
GIT_CLONE_ARGS=("$@")
|
|
|
|
|
2017-05-18 10:05:19 +00:00
|
|
|
# Look in the many different CI env vars for which branch we're
|
|
|
|
# building
|
|
|
|
if [[ "$TRAVIS" == true ]]; then
|
|
|
|
curbranch="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"
|
|
|
|
else
|
|
|
|
# ghprbSourceBranch for jenkins github pull request builder
|
|
|
|
# GIT_BRANCH for other jenkins builds
|
|
|
|
curbranch="${ghprbSourceBranch:-$GIT_BRANCH}"
|
|
|
|
# Otherwise look at the actual branch we're on
|
|
|
|
if [ -z "$curbranch" ]
|
|
|
|
then
|
|
|
|
curbranch=`git rev-parse --abbrev-ref HEAD`
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2017-06-07 09:35:08 +00: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.
|
2017-06-07 09:39:46 +00:00
|
|
|
curbranch=${curbranch#origin/}
|
2017-06-07 09:35:08 +00:00
|
|
|
|
2017-05-18 10:05:19 +00:00
|
|
|
echo "Determined branch to be $curbranch"
|
2017-05-17 15:11:34 +00:00
|
|
|
|
2017-06-01 17:02:51 +00:00
|
|
|
# clone a specific branch of a github repo
|
|
|
|
function clone() {
|
|
|
|
org=$1
|
|
|
|
repo=$2
|
|
|
|
branch=$3
|
|
|
|
git clone https://github.com/$org/$repo.git $repo --branch $branch \
|
|
|
|
"${GIT_CLONE_ARGS[@]}"
|
|
|
|
}
|
|
|
|
|
2017-05-17 15:11:34 +00:00
|
|
|
function dodep() {
|
|
|
|
org=$1
|
|
|
|
repo=$2
|
2017-06-01 17:02:51 +00:00
|
|
|
rm -rf $repo
|
|
|
|
clone $org $repo $curbranch || {
|
|
|
|
[ "$curbranch" != 'develop' ] && clone $org $repo develop
|
|
|
|
} || return $?
|
|
|
|
|
2017-08-08 08:43:40 +00:00
|
|
|
echo "$repo set to branch "`git -C "$repo" rev-parse --abbrev-ref HEAD`
|
2017-06-01 17:02:51 +00:00
|
|
|
|
|
|
|
mkdir -p node_modules
|
2018-09-17 23:46:13 +00:00
|
|
|
npm link "../$repo" # This does an npm install for us
|
2017-05-17 15:11:34 +00:00
|
|
|
}
|
|
|
|
|
2017-08-08 08:43:40 +00:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 17:02:51 +00:00
|
|
|
echo -en 'travis_fold:start:matrix-js-sdk\r'
|
|
|
|
echo 'Setting up matrix-js-sdk'
|
|
|
|
|
2017-05-17 15:11:34 +00:00
|
|
|
dodep matrix-org matrix-js-sdk
|
2017-06-01 17:02:51 +00:00
|
|
|
|
|
|
|
echo -en 'travis_fold:end:matrix-js-sdk\r'
|
|
|
|
|
2017-08-08 08:43:40 +00:00
|
|
|
##############################
|
|
|
|
|
2017-06-01 17:02:51 +00:00
|
|
|
echo -en 'travis_fold:start:matrix-react-sdk\r'
|
|
|
|
echo 'Setting up matrix-react-sdk'
|
|
|
|
|
2017-05-17 15:11:34 +00:00
|
|
|
dodep matrix-org matrix-react-sdk
|
2017-05-17 17:14:28 +00:00
|
|
|
|
2018-09-17 23:46:13 +00:00
|
|
|
# replace the version of js-sdk that got pulled into react-sdk with a link
|
2017-08-08 08:43:40 +00: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-17 23:46:13 +00:00
|
|
|
cd matrix-react-sdk
|
|
|
|
npm link ../matrix-js-sdk
|
|
|
|
cd ../
|
2017-06-01 17:02:51 +00:00
|
|
|
|
|
|
|
echo -en 'travis_fold:end:matrix-react-sdk\r'
|
|
|
|
|
2017-08-08 08:43:40 +00:00
|
|
|
##############################
|
|
|
|
|
2017-05-17 17:14:28 +00: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 17:02:51 +00:00
|
|
|
mkdir -p node_modules/.bin
|
|
|
|
ln -sfv ../matrix-react-sdk/scripts/reskindex.js node_modules/.bin/reskindex
|