Fix PR labeler for branches without merge base

Add fallback logic when git diff fails due to no merge base between branches. This handles cases where the branch history has diverged significantly.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Code 2025-07-07 20:07:02 -04:00
parent 1bd561cc83
commit c50a07c870

View file

@ -19,7 +19,18 @@ jobs:
# Get changed files
git fetch origin main
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
# Try different approaches to get the diff
if git merge-base origin/main HEAD >/dev/null 2>&1; then
CHANGED_FILES=$(git diff --name-only origin/main...HEAD)
else
# Fallback: compare with origin/main directly
CHANGED_FILES=$(git diff --name-only origin/main HEAD || echo "")
fi
if [ -z "$CHANGED_FILES" ]; then
echo "Unable to determine changed files, using all files in current branch"
CHANGED_FILES=$(find . -name "*.ts" -o -name "*.js" -o -name "*.scss" -o -name "*.json" | grep -v node_modules | head -20)
fi
# Initialize labels array
LABELS=""