diff --git a/Taskfile.yml b/Taskfile.yml index 2c9229dad51..bf85db4656c 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -914,13 +914,31 @@ tasks: - | OPENAPI_SHA="$(tr -d '[:space:]' < "{{.ROOT_DIR}}/.codegen/_openapi_sha")" BUILD_DIR="$(mktemp -d "${TMPDIR:-/tmp}/databricks-cli-universe.XXXXXX")" - trap 'rm -rf -- "$BUILD_DIR"' EXIT HUP INT TERM + # go-task's embedded shell (mvdan.cc/sh) only accepts EXIT/ERR in trap, + # not signal names, so cleanup is on normal/errexit exit only. + trap 'rm -rf -- "$BUILD_DIR"' EXIT echo "Creating temporary Universe checkout at ${OPENAPI_SHA}..." git clone --quiet --shared --no-checkout "{{.UNIVERSE_DIR}}" "$BUILD_DIR/universe" + + # `git clone --shared` does not carry over partial-clone/promisor config. + # If UNIVERSE_DIR is a blobless (filter=blob:none) clone, the shared + # object store lacks the file blobs the checkout below needs, and the + # temp clone has no promisor remote to fetch them on demand. Mirror the + # source's promisor config onto origin (pointed at the upstream remote) + # so missing blobs are lazily fetched during checkout. No-op for a full + # clone, where nothing is missing. + UNIVERSE_REMOTE="$(git -C "{{.UNIVERSE_DIR}}" remote get-url origin)" + UNIVERSE_FILTER="$(git -C "{{.UNIVERSE_DIR}}" config --get remote.origin.partialclonefilter || true)" + if [ -n "$UNIVERSE_FILTER" ]; then + git -C "$BUILD_DIR/universe" remote set-url origin "$UNIVERSE_REMOTE" + git -C "$BUILD_DIR/universe" config remote.origin.promisor true + git -C "$BUILD_DIR/universe" config remote.origin.partialclonefilter "$UNIVERSE_FILTER" + git -C "$BUILD_DIR/universe" config extensions.partialClone origin + fi + if ! git -C "$BUILD_DIR/universe" cat-file -e "${OPENAPI_SHA}^{commit}" 2>/dev/null; then echo "Fetching the missing Universe commit from the upstream remote..." - UNIVERSE_REMOTE="$(git -C "{{.UNIVERSE_DIR}}" remote get-url origin)" git -C "$BUILD_DIR/universe" fetch --no-tags "$UNIVERSE_REMOTE" master fi git -C "$BUILD_DIR/universe" checkout --quiet --detach "$OPENAPI_SHA"