From f0871e4f5e036b7fd29a5ae0ae0ae454185c0172 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 12 Oct 2016 12:27:37 -0400 Subject: [PATCH] update some scripts --- scripts/glide/checkout.sh | 27 +++++++++++++++++++++++++++ scripts/glide/parse.sh | 4 +++- scripts/glide/status.sh | 4 +++- scripts/glide/update.sh | 17 ++++++++++++++--- 4 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 scripts/glide/checkout.sh diff --git a/scripts/glide/checkout.sh b/scripts/glide/checkout.sh new file mode 100644 index 00000000..4dcc243c --- /dev/null +++ b/scripts/glide/checkout.sh @@ -0,0 +1,27 @@ +#! /bin/bash +set -u + +function parseGlide() { + cat $1 | grep -A1 $2 | grep -v $2 | awk '{print $2}' +} + + +# fetch and checkout vendored dep + +glide=$1 +lib=$2 + +echo "----------------------------------" +echo "Getting $lib ..." +go get -t github.com/tendermint/$lib/... + +VENDORED=$(parseGlide $glide $lib) +cd $GOPATH/src/github.com/tendermint/$lib +MASTER=$(git rev-parse origin/master) + +if [[ "$VENDORED" != "$MASTER" ]]; then + echo "... VENDORED != MASTER ($VENDORED != $MASTER)" + echo "... Checking out commit $VENDORED" + git checkout $VENDORED &> /dev/null +fi + diff --git a/scripts/glide/parse.sh b/scripts/glide/parse.sh index a92f70bc..86b5567b 100644 --- a/scripts/glide/parse.sh +++ b/scripts/glide/parse.sh @@ -3,6 +3,8 @@ set -euo pipefail LIB=$1 -GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock +if [[ "$GLIDE" == "" ]]; then + GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock +fi cat $GLIDE | grep -A1 $LIB | grep -v $LIB | awk '{print $2}' diff --git a/scripts/glide/status.sh b/scripts/glide/status.sh index 46ca5279..40503dbd 100644 --- a/scripts/glide/status.sh +++ b/scripts/glide/status.sh @@ -2,7 +2,9 @@ # for every github.com/tendermint dependency, warn is if its not synced with origin/master -GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock +if [[ "$GLIDE" == "" ]]; then + GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock +fi # make list of libs LIBS=($(grep "github.com/tendermint" $GLIDE | awk '{print $3}')) diff --git a/scripts/glide/update.sh b/scripts/glide/update.sh index 59d4de33..52d7c219 100644 --- a/scripts/glide/update.sh +++ b/scripts/glide/update.sh @@ -6,9 +6,12 @@ IFS=$'\n\t' LIB=$1 -GLIDE=$GOPATH/src/github.com/tendermint/tendermint/glide.lock +TMCORE=$GOPATH/src/github.com/tendermint/tendermint +if [[ "$GLIDE" == "" ]]; then + GLIDE=$TMCORE/glide.lock +fi -OLD_COMMIT=`bash scripts/glide/parse.sh $LIB` +OLD_COMMIT=`bash $TMCORE/scripts/glide/parse.sh $LIB` PWD=`pwd` cd $GOPATH/src/github.com/tendermint/$LIB @@ -16,4 +19,12 @@ cd $GOPATH/src/github.com/tendermint/$LIB NEW_COMMIT=$(git rev-parse HEAD) cd $PWD -sed -i "" "s/$OLD_COMMIT/$NEW_COMMIT/g" $GLIDE + +uname -a | grep Linux > /dev/null +if [[ "$?" == 0 ]]; then + # linux + sed -i "s/$OLD_COMMIT/$NEW_COMMIT/g" $GLIDE +else + # mac + sed -i "" "s/$OLD_COMMIT/$NEW_COMMIT/g" $GLIDE +fi