Improve worktree detection

This commit is contained in:
2025-10-22 19:35:38 -04:00
parent 018a91e216
commit b75597946d

View File

@@ -558,11 +558,11 @@ from_source() {
execute git clone "$src_url" "$SRC_DIR" execute git clone "$src_url" "$SRC_DIR"
fi fi
if [[ -d "$BUILD_DIR/.git" ]]; then # Reuse worktree if present; otherwise create it (support branches and tags)
# Keep worktree and reset to desired ref (handles branches and tags) if git -C "$BUILD_DIR" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
execute git -C "$BUILD_DIR" fetch origin --tags --prune execute git -C "$BUILD_DIR" fetch origin --tags --prune
execute git -C "$BUILD_DIR" reset --hard "origin/$ref" || execute git -C "$BUILD_DIR" reset --hard "origin/$ref" || \
execute git -C "$BUILD_DIR" reset --hard "$ref" || execute git -C "$BUILD_DIR" reset --hard "$ref" || \
execute git -C "$BUILD_DIR" checkout --detach "$ref" execute git -C "$BUILD_DIR" checkout --detach "$ref"
else else
execute git -C "$SRC_DIR" worktree prune --verbose execute git -C "$SRC_DIR" worktree prune --verbose