diff --git a/website/scripts/vercel-ignore.sh b/website/scripts/vercel-ignore.sh index b200e414f812..6423083bf11f 100755 --- a/website/scripts/vercel-ignore.sh +++ b/website/scripts/vercel-ignore.sh @@ -34,6 +34,12 @@ skip() { cd "$(git rev-parse --show-toplevel)" || build "cannot find repo root" +# Vercel's clone has no `origin` remote, so every fetch below would fail. Add +# one for the (public) repo; the clone is thrown away after the build. +git remote get-url origin >/dev/null 2>&1 || + { [ -n "${VERCEL_GIT_REPO_OWNER:-}" ] && [ -n "${VERCEL_GIT_REPO_SLUG:-}" ] && + git remote add origin "https://github.com/$VERCEL_GIT_REPO_OWNER/$VERCEL_GIT_REPO_SLUG.git"; } + # Builds if site paths changed between $1 and $2 (or the diff fails); else skips. decide() { local files diff --git a/website/scripts/vercel-ignore.test.sh b/website/scripts/vercel-ignore.test.sh index c77218f6a02c..eabf8cc6f007 100755 --- a/website/scripts/vercel-ignore.test.sh +++ b/website/scripts/vercel-ignore.test.sh @@ -232,10 +232,16 @@ for branch in far-pkg far-site; do clone="$(mktemp -d)" git clone -q --depth=10 --branch "$branch" "file://$origin_repo" "$clone" git -C "$clone" branch -f master HEAD + # Like Vercel's clone: no `origin` remote, so the script must fetch by URL. + git -C "$clone" remote remove origin repo="$clone" want=skip [ "$branch" = far-site ] && want=build - expect "$want" "shallow clone, fork far behind master ($branch)" "$branch" + GIT_CONFIG_COUNT=3 \ + GIT_CONFIG_KEY_2="url.file://$origin_repo.insteadOf" \ + GIT_CONFIG_VALUE_2=https://github.com/test-owner/test-repo.git \ + VERCEL_GIT_REPO_OWNER=test-owner VERCEL_GIT_REPO_SLUG=test-repo \ + expect "$want" "shallow clone without origin, fork far behind master ($branch)" "$branch" repo="$origin_repo" rm -rf "$clone" done