From e16a65bfe0541344f1aaecd9b116c07c839e89c8 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Mon, 19 Oct 2026 13:18:25 +0200 Subject: [PATCH 1/4] fix: fetch full history when cognitive complexity is enabled The checkout expression `inputs.run_cognitive_complexity && 0 || 1` always evaluates to `1` because `0` is falsy in GitHub expressions, so the clone stayed shallow and the cognitive complexity step still failed to resolve a merge base. Negate the condition so the truthy branch is non-zero. --- .github/workflows/dart_package.yml | 5 +++-- .github/workflows/flutter_package.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dart_package.yml b/.github/workflows/dart_package.yml index d3b240d..50fe7d8 100644 --- a/.github/workflows/dart_package.yml +++ b/.github/workflows/dart_package.yml @@ -143,8 +143,9 @@ jobs: with: # Cognitive complexity resolves a merge base against the diff base, # which requires full history. Other runs keep the default shallow - # clone for speed. - fetch-depth: ${{ inputs.run_cognitive_complexity && 0 || 1 }} + # clone for speed. The condition is negated because `0` is falsy in + # expressions, so `cond && 0 || 1` would always evaluate to `1`. + fetch-depth: ${{ !inputs.run_cognitive_complexity && 1 || 0 }} - name: 🎯 Setup Dart uses: dart-lang/setup-dart@v1.8.1 diff --git a/.github/workflows/flutter_package.yml b/.github/workflows/flutter_package.yml index 25cda23..e038df3 100644 --- a/.github/workflows/flutter_package.yml +++ b/.github/workflows/flutter_package.yml @@ -156,8 +156,9 @@ jobs: with: # Cognitive complexity resolves a merge base against the diff base, # which requires full history. Other runs keep the default shallow - # clone for speed. - fetch-depth: ${{ inputs.run_cognitive_complexity && 0 || 1 }} + # clone for speed. The condition is negated because `0` is falsy in + # expressions, so `cond && 0 || 1` would always evaluate to `1`. + fetch-depth: ${{ !inputs.run_cognitive_complexity && 1 || 0 }} - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2.23.0 From 62ef0b3988fe50a564443541374224c76e09f28d Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Mon, 19 Oct 2026 14:27:16 +0200 Subject: [PATCH 2/4] refactor: split checkout into if-gated steps for cognitive complexity Gate full-history and shallow checkouts with step-level `if:` instead of computing fetch-depth from the toggle, keeping enable/disable logic separate from clone depth as suggested in review. --- .github/workflows/dart_package.yml | 13 ++++++++----- .github/workflows/flutter_package.yml | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/dart_package.yml b/.github/workflows/dart_package.yml index 50fe7d8..e474b93 100644 --- a/.github/workflows/dart_package.yml +++ b/.github/workflows/dart_package.yml @@ -139,13 +139,16 @@ jobs: steps: - name: 📚 Git Checkout + if: ${{ !inputs.run_cognitive_complexity }} + uses: actions/checkout@v7 + + # Cognitive complexity resolves a merge base against the diff base, + # which requires full history. + - name: 📚 Git Checkout (full history) + if: ${{ inputs.run_cognitive_complexity }} uses: actions/checkout@v7 with: - # Cognitive complexity resolves a merge base against the diff base, - # which requires full history. Other runs keep the default shallow - # clone for speed. The condition is negated because `0` is falsy in - # expressions, so `cond && 0 || 1` would always evaluate to `1`. - fetch-depth: ${{ !inputs.run_cognitive_complexity && 1 || 0 }} + fetch-depth: 0 - name: 🎯 Setup Dart uses: dart-lang/setup-dart@v1.8.1 diff --git a/.github/workflows/flutter_package.yml b/.github/workflows/flutter_package.yml index e038df3..3ff1e6f 100644 --- a/.github/workflows/flutter_package.yml +++ b/.github/workflows/flutter_package.yml @@ -152,13 +152,16 @@ jobs: steps: - name: 📚 Git Checkout + if: ${{ !inputs.run_cognitive_complexity }} + uses: actions/checkout@v7 + + # Cognitive complexity resolves a merge base against the diff base, + # which requires full history. + - name: 📚 Git Checkout (full history) + if: ${{ inputs.run_cognitive_complexity }} uses: actions/checkout@v7 with: - # Cognitive complexity resolves a merge base against the diff base, - # which requires full history. Other runs keep the default shallow - # clone for speed. The condition is negated because `0` is falsy in - # expressions, so `cond && 0 || 1` would always evaluate to `1`. - fetch-depth: ${{ !inputs.run_cognitive_complexity && 1 || 0 }} + fetch-depth: 0 - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2.23.0 From 1066c3311cdfbf9600cc843076ad303bc28a7160 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Mon, 19 Oct 2026 14:28:22 +0200 Subject: [PATCH 3/4] style: match expression spacing in checkout conditions --- .github/workflows/dart_package.yml | 4 ++-- .github/workflows/flutter_package.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dart_package.yml b/.github/workflows/dart_package.yml index e474b93..1d3097f 100644 --- a/.github/workflows/dart_package.yml +++ b/.github/workflows/dart_package.yml @@ -139,13 +139,13 @@ jobs: steps: - name: 📚 Git Checkout - if: ${{ !inputs.run_cognitive_complexity }} + if: ${{!inputs.run_cognitive_complexity}} uses: actions/checkout@v7 # Cognitive complexity resolves a merge base against the diff base, # which requires full history. - name: 📚 Git Checkout (full history) - if: ${{ inputs.run_cognitive_complexity }} + if: ${{inputs.run_cognitive_complexity}} uses: actions/checkout@v7 with: fetch-depth: 0 diff --git a/.github/workflows/flutter_package.yml b/.github/workflows/flutter_package.yml index 3ff1e6f..4512454 100644 --- a/.github/workflows/flutter_package.yml +++ b/.github/workflows/flutter_package.yml @@ -152,13 +152,13 @@ jobs: steps: - name: 📚 Git Checkout - if: ${{ !inputs.run_cognitive_complexity }} + if: ${{!inputs.run_cognitive_complexity}} uses: actions/checkout@v7 # Cognitive complexity resolves a merge base against the diff base, # which requires full history. - name: 📚 Git Checkout (full history) - if: ${{ inputs.run_cognitive_complexity }} + if: ${{inputs.run_cognitive_complexity}} uses: actions/checkout@v7 with: fetch-depth: 0 From 8b9ebc94f9616aa97921f9078dad350d7821f155 Mon Sep 17 00:00:00 2001 From: Marcos Sevilla Date: Mon, 19 Oct 2026 14:29:56 +0200 Subject: [PATCH 4/4] refactor: compute checkout fetch depth in job env Replace the two if-gated checkout steps with a single checkout that reads a job-level FETCH_DEPTH. String literals keep '0' truthy so the full-history branch is actually taken. --- .github/workflows/dart_package.yml | 15 +++++++-------- .github/workflows/flutter_package.yml | 15 +++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.github/workflows/dart_package.yml b/.github/workflows/dart_package.yml index 1d3097f..4d79aa5 100644 --- a/.github/workflows/dart_package.yml +++ b/.github/workflows/dart_package.yml @@ -137,18 +137,17 @@ jobs: runs-on: ${{inputs.runs_on}} timeout-minutes: ${{inputs.timeout_minutes}} + env: + # Cognitive complexity resolves a merge base against the diff base, + # which requires full history. Other runs keep a shallow clone. Values + # are strings because the number `0` is falsy in expressions. + FETCH_DEPTH: ${{inputs.run_cognitive_complexity && '0' || '1'}} + steps: - name: 📚 Git Checkout - if: ${{!inputs.run_cognitive_complexity}} - uses: actions/checkout@v7 - - # Cognitive complexity resolves a merge base against the diff base, - # which requires full history. - - name: 📚 Git Checkout (full history) - if: ${{inputs.run_cognitive_complexity}} uses: actions/checkout@v7 with: - fetch-depth: 0 + fetch-depth: ${{env.FETCH_DEPTH}} - name: 🎯 Setup Dart uses: dart-lang/setup-dart@v1.8.1 diff --git a/.github/workflows/flutter_package.yml b/.github/workflows/flutter_package.yml index 4512454..0dd457e 100644 --- a/.github/workflows/flutter_package.yml +++ b/.github/workflows/flutter_package.yml @@ -150,18 +150,17 @@ jobs: runs-on: ${{inputs.runs_on}} timeout-minutes: ${{inputs.timeout_minutes}} + env: + # Cognitive complexity resolves a merge base against the diff base, + # which requires full history. Other runs keep a shallow clone. Values + # are strings because the number `0` is falsy in expressions. + FETCH_DEPTH: ${{inputs.run_cognitive_complexity && '0' || '1'}} + steps: - name: 📚 Git Checkout - if: ${{!inputs.run_cognitive_complexity}} - uses: actions/checkout@v7 - - # Cognitive complexity resolves a merge base against the diff base, - # which requires full history. - - name: 📚 Git Checkout (full history) - if: ${{inputs.run_cognitive_complexity}} uses: actions/checkout@v7 with: - fetch-depth: 0 + fetch-depth: ${{env.FETCH_DEPTH}} - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2.23.0