
1) imported glog to third_party (previous commit) 2) add support for third_party/update.sh to update just one pkg 3) search-and-replace: s/log.Printf/glog.Infof/ s/log.Print/glog.Info/ s/log.Fatalf/glog.Fatalf/ s/log.Fatal/glog.Fatal/ 4) convert glog.Info.*, err into glog.Error* Adds some util interfaces to logging and calls them from each cmd, which will set the default log output to write to glog. Pass glog-wrapped Loggers to etcd for logging. Log files will go to /tmp - we should probably follow this up with a default log dir for each cmd. The glog lib is sort of weak in that it only flushes every 30 seconds, so we spin up our own flushing goroutine.
65 lines
1.4 KiB
Bash
Executable File
65 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
if (( $(git status --porcelain 2>/dev/null | grep "^M" | wc -l) > 0 )); then
|
|
echo "You can't have any staged files in git when updating packages."
|
|
echo "Either commit them or unstage them to continue."
|
|
exit 1
|
|
fi
|
|
|
|
THIRD_PARTY_DIR=$(dirname $0)
|
|
cd $THIRD_PARTY_DIR
|
|
|
|
. ./deps.sh
|
|
|
|
if [ $# -gt 0 ]; then
|
|
PACKAGES="$@"
|
|
fi
|
|
|
|
# Create a temp GOPATH root. It must be an absolute path
|
|
mkdir -p ../output/go_dep_update
|
|
cd ../output/go_dep_update
|
|
TMP_GO_ROOT=$PWD
|
|
cd -
|
|
export GOPATH=${TMP_GO_ROOT}
|
|
|
|
for p in $PACKAGES; do
|
|
echo "Fetching $p"
|
|
|
|
# this is the target directory
|
|
mkdir -p src/$p
|
|
|
|
# This will checkout the project into src
|
|
go get -u -d $p
|
|
|
|
# The go get path
|
|
gp=$TMP_GO_ROOT/src/$p
|
|
|
|
# Attempt to find the commit hash of the repo
|
|
cd $gp
|
|
|
|
HEAD=
|
|
REL_PATH=$(git rev-parse --show-prefix 2>/dev/null)
|
|
if [[ -z "$HEAD" && $REL_PATH != *target/go_dep_update* ]]; then
|
|
# Grab the head if it is git
|
|
HEAD=$(git rev-parse HEAD)
|
|
fi
|
|
|
|
# Grab the head if it is mercurial
|
|
if [[ -z "$HEAD" ]] && hg root >/dev/null 2>&1; then
|
|
HEAD=$(hg id -i)
|
|
fi
|
|
|
|
cd -
|
|
|
|
# Copy the code into the final directory
|
|
rsync -a -z -r --exclude '.git/' --exclude '.hg/' $TMP_GO_ROOT/src/$p/ src/$p
|
|
|
|
# Make a nice commit about what everything bumped to
|
|
git add src/$p
|
|
if ! git diff --cached --exit-code > /dev/null 2>&1; then
|
|
git commit -m "bump($p): $HEAD"
|
|
fi
|
|
done
|