Fix resources isues 31

This commit is contained in:
2026-01-23 05:50:50 +01:00
parent fc565753ec
commit fefccafde0

View File

@@ -24,7 +24,7 @@ spec:
- name: depth - name: depth
type: string type: string
description: Git clone depth (0 for full history, minimum 2 for change detection) description: Git clone depth (0 for full history, minimum 2 for change detection)
default: "2" default: "10"
results: results:
- name: commit-sha - name: commit-sha
description: The commit SHA that was checked out description: The commit SHA that was checked out
@@ -66,6 +66,7 @@ spec:
git config --global --add safe.directory "$OUTPUT_PATH" git config --global --add safe.directory "$OUTPUT_PATH"
# Clone with depth for faster checkout # Clone with depth for faster checkout
# Note: We need at least 2 commits for change detection (current + parent)
if [ "$DEPTH" = "0" ]; then if [ "$DEPTH" = "0" ]; then
echo "Cloning full repository..." echo "Cloning full repository..."
git clone "$URL" "$OUTPUT_PATH" git clone "$URL" "$OUTPUT_PATH"
@@ -76,15 +77,42 @@ spec:
cd "$OUTPUT_PATH" cd "$OUTPUT_PATH"
# Fetch the specific revision if needed # If revision is a specific commit SHA (40 hex chars), we need special handling
if [ "$REVISION" != "main" ] && [ "$REVISION" != "master" ]; then if echo "$REVISION" | grep -qE '^[0-9a-f]{40}$'; then
echo "Fetching revision: $REVISION" echo "Revision is a commit SHA: $REVISION"
git fetch --depth 1 origin "$REVISION" 2>/dev/null || true
# Check if commit is already in the clone
if ! git cat-file -e "$REVISION" 2>/dev/null; then
echo "Commit not in shallow clone, fetching with history..."
# Fetch more history to include the specific commit
git fetch --deepen="$DEPTH" origin main 2>/dev/null || true
git fetch origin "$REVISION" 2>/dev/null || true
fi
# Ensure we have the parent commit for change detection
PARENT_SHA=$(git rev-parse "$REVISION^" 2>/dev/null || echo "")
if [ -z "$PARENT_SHA" ]; then
echo "Parent commit not available, deepening history..."
git fetch --deepen=10 origin 2>/dev/null || true
fi
elif [ "$REVISION" != "main" ] && [ "$REVISION" != "master" ]; then
echo "Fetching branch/tag: $REVISION"
git fetch --depth "$DEPTH" origin "$REVISION" 2>/dev/null || true
fi fi
# Checkout the revision # Checkout the revision
echo "Checking out: $REVISION" echo "Checking out: $REVISION"
git checkout "$REVISION" 2>/dev/null || git checkout "origin/$REVISION" git checkout "$REVISION" 2>/dev/null || git checkout "origin/$REVISION" 2>/dev/null || git checkout FETCH_HEAD
# Verify we have enough history for change detection
COMMIT_COUNT=$(git rev-list --count HEAD 2>/dev/null || echo "0")
echo "Commits available after checkout: $COMMIT_COUNT"
if [ "$COMMIT_COUNT" -lt 2 ]; then
echo "Warning: Not enough history, fetching more..."
git fetch --deepen=10 origin 2>/dev/null || true
COMMIT_COUNT=$(git rev-list --count HEAD 2>/dev/null || echo "0")
echo "Commits available after deepen: $COMMIT_COUNT"
fi
# Get commit info # Get commit info
COMMIT_SHA=$(git rev-parse HEAD) COMMIT_SHA=$(git rev-parse HEAD)