2017-02-13 14:01:54 -05:00
|
|
|
#!/usr/bin/env bash
|
2014-04-04 02:37:50 -04:00
|
|
|
|
2016-10-12 15:25:49 -04:00
|
|
|
set -e -o pipefail
|
|
|
|
|
2019-01-09 20:23:38 -05:00
|
|
|
if [ -z "$VALIDATE_UPSTREAM" ]; then
|
2014-04-04 02:37:50 -04:00
|
|
|
# this is kind of an expensive check, so let's not do this twice if we
|
|
|
|
# are running more than one validate bundlescript
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2019-01-30 16:16:16 -05:00
|
|
|
VALIDATE_REPO="${VALIDATE_REPO:-https://github.com/docker/docker.git}"
|
|
|
|
VALIDATE_BRANCH="${VALIDATE_BRANCH:-master}"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2014-04-04 02:37:50 -04:00
|
|
|
VALIDATE_HEAD="$(git rev-parse --verify HEAD)"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2019-02-04 14:05:10 -05:00
|
|
|
if [ -z "$VALIDATE_ORIGIN_BRANCH" ]; then
|
|
|
|
git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH"
|
|
|
|
VALIDATE_ORIGIN_BRANCH=FETCH_HEAD
|
|
|
|
fi
|
|
|
|
VALIDATE_UPSTREAM="$(git rev-parse --verify $VALIDATE_ORIGIN_BRANCH)"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2014-04-04 02:37:50 -04:00
|
|
|
VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD"
|
|
|
|
VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"
|
2015-03-25 13:38:17 -04:00
|
|
|
|
2014-04-04 02:37:50 -04:00
|
|
|
validate_diff() {
|
2019-01-09 20:23:38 -05:00
|
|
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
2014-04-04 02:37:50 -04:00
|
|
|
git diff "$VALIDATE_COMMIT_DIFF" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
validate_log() {
|
2019-01-09 20:23:38 -05:00
|
|
|
if [ "$VALIDATE_UPSTREAM" != "$VALIDATE_HEAD" ]; then
|
2014-04-04 02:37:50 -04:00
|
|
|
git log "$VALIDATE_COMMIT_LOG" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
fi
|