From c6e4d80f1e47519df81ff1193b0b0628a5aac03d Mon Sep 17 00:00:00 2001 From: Marcelo Gobetti Date: Tue, 3 Mar 2026 20:52:40 -0300 Subject: [PATCH] Detect default branch and fetch it before diffing git symbolic-ref finds the actual default branch name (handles repos using master or other names), and an explicit git fetch ensures origin/ exists locally before the diff. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/auto-fill-pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/auto-fill-pr.yml b/.github/workflows/auto-fill-pr.yml index 0167afd..bb86695 100644 --- a/.github/workflows/auto-fill-pr.yml +++ b/.github/workflows/auto-fill-pr.yml @@ -39,9 +39,13 @@ jobs: # Determine base ref (github.base_ref is empty when triggered via workflow_call) BASE_REF="${{ github.base_ref }}" if [ -z "$BASE_REF" ]; then - BASE_REF="main" + # Detect default branch from remote + BASE_REF=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|origin/||' || echo "main") fi + # Ensure the base ref is fetched locally + git fetch origin ${BASE_REF} + # Get the diff (limited to avoid token overflow) DIFF=$(git diff origin/${BASE_REF}...HEAD -- . ':!package-lock.json' ':!yarn.lock' ':!*.min.js' ':!*.min.css' | head -c 30000)