From 1c0873d8f1fafd1fac42d3917945d879c8ca92a9 Mon Sep 17 00:00:00 2001 From: Saagar Date: Sun, 17 May 2026 15:41:12 -0700 Subject: [PATCH] ci: detect default branch coverage by commit --- scripts/ci/run-diff-coverage.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/ci/run-diff-coverage.sh b/scripts/ci/run-diff-coverage.sh index 2b580ae..6a1c588 100755 --- a/scripts/ci/run-diff-coverage.sh +++ b/scripts/ci/run-diff-coverage.sh @@ -20,8 +20,18 @@ fi current_branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)" github_ref_name="${GITHUB_REF_NAME:-}" +github_ref="${GITHUB_REF:-}" compare_ref="${compare_branch#origin/}" -if [[ -z "$base_ref" && ( "$current_branch" == "$compare_ref" || "$github_ref_name" == "$compare_ref" ) ]]; then +head_sha="$(git rev-parse HEAD 2>/dev/null || true)" +compare_sha="$(git rev-parse "$compare_branch" 2>/dev/null || true)" +is_default_branch_run=false +if [[ "$current_branch" == "$compare_ref" || "$github_ref_name" == "$compare_ref" || "$github_ref" == "refs/heads/$compare_ref" ]]; then + is_default_branch_run=true +elif [[ -n "$head_sha" && "$head_sha" == "$compare_sha" ]]; then + is_default_branch_run=true +fi + +if [[ -z "$base_ref" && "$is_default_branch_run" == "true" ]]; then echo "Default branch coverage run detected; skipping diff coverage." exit 0 fi