Merge pull request #33237 from lavalamp/godepuserfriendly

Automatic merge from submit-queue

make verify godeps help you fix your problems instead of taunting you

This should save people so much time

(the changes are pretty minor, but the indentation makes them look major)
This commit is contained in:
Kubernetes Submit Queue 2016-09-21 23:30:53 -07:00 committed by GitHub
commit bf6cfd33e1

View File

@ -52,9 +52,14 @@ fi
# Create a nice clean place to put our new godeps # Create a nice clean place to put our new godeps
_tmpdir="$(mktemp -d -t gopath.XXXXXX)" _tmpdir="$(mktemp -d -t gopath.XXXXXX)"
KEEP_TMP=false
function cleanup { function cleanup {
echo "Removing ${_tmpdir}" if [ "${KEEP_TMP}" == "true" ]; then
rm -rf "${_tmpdir}" echo "Leaving ${_tmpdir} for you to examine or copy. Please delete it manually when finished. (rm -rf ${_tmpdir})"
else
echo "Removing ${_tmpdir}"
rm -rf "${_tmpdir}"
fi
} }
trap cleanup EXIT trap cleanup EXIT
@ -67,48 +72,67 @@ _kubetmp="${_kubetmp}/kubernetes"
# Do all our work in the new GOPATH # Do all our work in the new GOPATH
export GOPATH="${_tmpdir}" export GOPATH="${_tmpdir}"
cd "${_kubetmp}"
# Build the godep tool pushd "${_kubetmp}" 2>&1 > /dev/null
go get -u github.com/tools/godep 2>/dev/null # Build the godep tool
GODEP="${GOPATH}/bin/godep" go get -u github.com/tools/godep 2>/dev/null
pin-godep() { GODEP="${GOPATH}/bin/godep"
pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null pin-godep() {
git checkout "$1" pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null
"${GODEP}" go install git checkout "$1"
popd > /dev/null "${GODEP}" go install
} popd > /dev/null
# Use to following if we ever need to pin godep to a specific version again }
#pin-godep 'v63' # Use to following if we ever need to pin godep to a specific version again
#pin-godep 'v63'
# Fill out that nice clean place with the kube godeps # Fill out that nice clean place with the kube godeps
echo "Starting to download all kubernetes godeps. This takes a while" echo "Starting to download all kubernetes godeps. This takes a while"
"${GODEP}" restore "${GODEP}" restore
echo "Download finished" echo "Download finished"
# Destroy deps in the copy of the kube tree # Destroy deps in the copy of the kube tree
rm -rf ./Godeps ./vendor rm -rf ./Godeps ./vendor
# For some reason the kube tree needs to be a git repo for the godep tool to # For some reason the kube tree needs to be a git repo for the godep tool to
# run. Doesn't make sense. # run. Doesn't make sense.
git init > /dev/null 2>&1 git init > /dev/null 2>&1
# Recreate the Godeps using the nice clean set we just downloaded # Recreate the Godeps using the nice clean set we just downloaded
hack/godep-save.sh hack/godep-save.sh
popd 2>&1 > /dev/null
# Test for diffs ret=0
if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' --ignore-matching-line='^\s*\"GodepVersion\":' --ignore-matching-lines='^\s*\"Comment\":' ${KUBE_ROOT}/Godeps/Godeps.json ${_kubetmp}/Godeps/Godeps.json)"; then
echo "Your Godeps.json is different:"
echo "${_out}"
echo "Godeps Verify failed."
exit 1
fi
if ! _out="$(diff -Naupr ${KUBE_ROOT}/vendor ${_kubetmp}/vendor)"; then pushd "${KUBE_ROOT}" 2>&1 > /dev/null
echo "Your vendored results are different:" # Test for diffs
echo "${_out}" if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' --ignore-matching-line='^\s*\"GodepVersion\":' --ignore-matching-lines='^\s*\"Comment\":' Godeps/Godeps.json ${_kubetmp}/Godeps/Godeps.json)"; then
echo "Godeps Verify failed." echo "Your Godeps.json is different:"
exit 1 echo "${_out}"
echo "Godeps Verify failed."
echo "${_out}" > godepdiff.patch
echo "If you're seeing this locally, run the below command to fix your Godeps.json:"
echo "patch -p0 < godepdiff.patch"
echo "(The above output can be saved as godepdiff.patch if you're not running this locally)"
KEEP_TMP=true
ret=1
fi
if ! _out="$(diff -Naupr vendor ${_kubetmp}/vendor)"; then
echo "Your vendored results are different:"
echo "${_out}"
echo "Godeps Verify failed."
echo "${_out}" > vendordiff.patch
echo "If you're seeing this locally, run the below command to fix your directories:"
echo "patch -p0 < vendordiff.patch"
echo "(The above output can be saved as godepdiff.patch if you're not running this locally)"
KEEP_TMP=true
ret=1
fi
popd 2>&1 > /dev/null
if [[ ${ret} > 0 ]]; then
exit ${ret}
fi fi
echo "Godeps Verified." echo "Godeps Verified."