From c14d8be35a9f8d1af2097c24a2ab56a7c6ee4f43 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Mon, 4 Feb 2019 19:05:10 +0000 Subject: [PATCH] hack: no need to git fetch in CI CIs are assumed to do a git fetch and git merge before running tests. Therefore, no need for a git fetch inside our validate scripts in CI. If VALIDATE_ORIGIN_BRANCH is set, then git fetch is skipped and VALIDATE_ORIGIN_BRANCH is used in validate scripts. Otherwise, behavior is unchanged. Signed-off-by: Tibor Vass (cherry picked from commit feb70fd5c9e2fb3f300e953dd83053f0830f3895) Signed-off-by: Sebastiaan van Stijn Upstream-commit: 7b9ec00eec7ffe745ebd2f807daa50d84b3e10e7 Component: engine --- components/engine/Makefile | 2 ++ components/engine/hack/validate/.validate | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/engine/Makefile b/components/engine/Makefile index 28c87bdda4..7767409a6f 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -17,6 +17,7 @@ export DOCKER_GITCOMMIT # against these are used in hack/validate/.validate to check what changed in the PR. export VALIDATE_REPO export VALIDATE_BRANCH +export VALIDATE_ORIGIN_BRANCH # env vars passed through directly to Docker's build scripts # to allow things like `make KEEPBUNDLE=1 binary` easily @@ -56,6 +57,7 @@ DOCKER_ENVS := \ -e TIMEOUT \ -e VALIDATE_REPO \ -e VALIDATE_BRANCH \ + -e VALIDATE_ORIGIN_BRANCH \ -e HTTP_PROXY \ -e HTTPS_PROXY \ -e NO_PROXY \ diff --git a/components/engine/hack/validate/.validate b/components/engine/hack/validate/.validate index acc985d41b..6ed3a59a73 100644 --- a/components/engine/hack/validate/.validate +++ b/components/engine/hack/validate/.validate @@ -11,8 +11,11 @@ if [ -z "$VALIDATE_UPSTREAM" ]; then VALIDATE_HEAD="$(git rev-parse --verify HEAD)" - git fetch -q "$VALIDATE_REPO" "refs/heads/$VALIDATE_BRANCH" - VALIDATE_UPSTREAM="$(git rev-parse --verify FETCH_HEAD)" + 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)" VALIDATE_COMMIT_LOG="$VALIDATE_UPSTREAM..$VALIDATE_HEAD" VALIDATE_COMMIT_DIFF="$VALIDATE_UPSTREAM...$VALIDATE_HEAD"