tendermint/scripts/dep_utils/checkout.sh

36 lines
727 B
Bash
Raw Normal View History

2016-10-12 09:27:37 -07:00
#! /bin/bash
2018-02-27 23:15:40 -08:00
set -ex
2018-02-27 23:15:40 -08:00
set +u
if [[ "$DEP" == "" ]]; then
2018-02-28 00:24:26 -08:00
DEP=$GOPATH/src/github.com/tendermint/tendermint/Gopkg.lock
2018-02-27 23:15:40 -08:00
fi
set -u
2018-02-28 00:24:26 -08:00
2016-10-12 09:27:37 -07:00
set -u
2018-02-27 05:20:56 -08:00
function getVendoredVersion() {
2018-02-27 23:15:40 -08:00
grep -A100 "$LIB" "$DEP" | grep revision | head -n1 | grep -o '"[^"]\+"' | cut -d '"' -f 2
2016-10-12 09:27:37 -07:00
}
# fetch and checkout vendored dep
2018-02-27 05:20:56 -08:00
lib=$1
2016-10-12 09:27:37 -07:00
echo "----------------------------------"
echo "Getting $lib ..."
2018-02-27 05:20:56 -08:00
go get -t "github.com/tendermint/$lib/..."
2016-10-12 09:27:37 -07:00
2018-02-27 05:20:56 -08:00
VENDORED=$(getVendoredVersion "$lib")
cd "$GOPATH/src/github.com/tendermint/$lib" || exit
2016-10-12 09:27:37 -07:00
MASTER=$(git rev-parse origin/master)
if [[ "$VENDORED" != "$MASTER" ]]; then
echo "... VENDORED != MASTER ($VENDORED != $MASTER)"
echo "... Checking out commit $VENDORED"
2018-02-27 05:20:56 -08:00
git checkout "$VENDORED" &> /dev/null
2016-10-12 09:27:37 -07:00
fi