From e6f2719b6d5586d493c38eb2b2b4e8149b1daeaa Mon Sep 17 00:00:00 2001 From: Anuj Hydrabadi Date: Wed, 10 Sep 2025 17:15:29 +0530 Subject: [PATCH] fix: handle null SHA for first commit in git diff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issue where action fails with "fatal: Invalid symmetric difference expression 0000000000000000000000000000000000000000...HEAD" when there is only one commit in the repository. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module-preview-action/action.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/module-preview-action/action.yml b/module-preview-action/action.yml index f102947..d425b4f 100644 --- a/module-preview-action/action.yml +++ b/module-preview-action/action.yml @@ -117,7 +117,14 @@ runs: fi echo "🔍 Finding changed directories... git diff ($BASE_REF/$HEAD_REF)" - CHANGED_DIRS=$(git diff --name-only "$BASE_REF...HEAD" | xargs -I {} dirname {} | sort -u) + + # Handle the case when BASE_REF is the null SHA (first commit) + if [ "$BASE_REF" = "0000000000000000000000000000000000000000" ]; then + echo "📝 First commit detected, getting all files in HEAD" + CHANGED_DIRS=$(git diff --name-only --diff-filter=A HEAD | xargs -I {} dirname {} | sort -u) + else + CHANGED_DIRS=$(git diff --name-only "$BASE_REF...HEAD" | xargs -I {} dirname {} | sort -u) + fi echo "📝 Changed directories detected: $CHANGED_DIRS" FACETS_DIRS=""