#!/usr/bin/env bash # Shallow work/ checkout for GitHub Actions. # # Unlike apply-patches.sh this does not clone upstream/ (that copy is a full # history clone for make update). CI only needs the pinned SHA + patches/. source "$(dirname "${BASH_SOURCE[0]}")/lib.sh" REV="$(read_rev)" info "Fetching upstream ${REV:0:12} -> work/" rm -rf "$WORK_DIR" git init "$WORK_DIR" git -C "$WORK_DIR" remote add origin "$UPSTREAM_URL" git -C "$WORK_DIR" fetch --depth 1 origin "$REV" git -C "$WORK_DIR" checkout --force --detach FETCH_HEAD git -C "$WORK_DIR" checkout -B "$WORK_BRANCH" git -C "$WORK_DIR" tag -f "$BASE_TAG" git -C "$WORK_DIR" config user.email "41898282+github-actions[bot]@users.noreply.github.com" git -C "$WORK_DIR" config user.name "github-actions[bot]" shopt -s nullglob patches=("$PATCHES_DIR"/*.patch) shopt -u nullglob if ((${#patches[@]})); then git -C "$WORK_DIR" am --3way --keep-cr --whitespace=nowarn "${patches[@]}" fi info "work/ ready: upstream ${REV:0:12} + ${#patches[@]} patch(es)"