Skip to content

fix: issue body must report compare.ahead_by, not commits.length#61

Merged
Jamkris merged 1 commit into
mainfrom
fix/issue-body-count
May 12, 2026
Merged

fix: issue body must report compare.ahead_by, not commits.length#61
Jamkris merged 1 commit into
mainfrom
fix/issue-body-count

Conversation

@Jamkris
Copy link
Copy Markdown
Owner

@Jamkris Jamkris commented May 12, 2026

Summary

Smoke run after PR #59 merged surfaced a title/body inconsistency on tracking issue #60. Title said "1521 new commits" (correct); body said "has 250 commit(s) ahead" and "250 total, showing first 50" (wrong).

Root cause: the GitHub compare endpoint caps commits[] at 250 per response regardless of the true delta. formatIssueBody was using commits.length for the intro and the details summary, so any delta above 250 silently displays as 250.

Fix

  • scripts/lib/upstream-drift.js — add required totalCount param to formatIssueBody. Use it for:
    • intro: "has N commit(s) ahead"
    • details summary: "showing first X of N"
    • truncation footer: "… and (N − shown) more"
  • scripts/upstream/check-upstream-drift.jsbuildIssueContent passes compare.ahead_by as totalCount.

Tests

  • New: API-cap scenario (totalCount=1521, commits.length=250) — body must not mention 250 anywhere.
  • New: total-fits-in-display scenario — simple Commits (N) summary, no truncation footer.
  • New: rejects negative / non-integer totalCount.
  • Existing tests updated to pass totalCount.

Verification

Before / after (issue #60 body intro)

- Upstream `affaan-m/everything-claude-code` has **250** commit(s) ahead of the recorded baseline.
+ Upstream `affaan-m/everything-claude-code` has **1521** commit(s) ahead of the recorded baseline.
- <summary>Commits (250 total, showing first 50)</summary>
+ <summary>Commits (showing first 50 of 1521)</summary>
- - _… and 200 more. See the [full diff](…)._
+ - _… and 1471 more. See the [full diff](…)._

Summary by cubic

Fixes incorrect commit counts in the upstream drift tracking issue body when more than 250 commits are ahead. The body now uses compare.ahead_by for all counts, matching the title and avoiding the GitHub compare API cap.

  • Bug Fixes
    • formatIssueBody now accepts totalCount and uses it in the intro, details summary, and truncation text.
    • buildIssueContent passes compare.ahead_by as totalCount to avoid relying on capped commits[].
    • Added tests for API-cap scenarios, no-truncation cases, and invalid totalCount.

Written for commit 2e0c8fb. Summary will update on new commits.

Summary by CodeRabbit

  • Improvements
    • Upstream drift tracking now accurately counts all commits ahead of upstream sources, even when API results are truncated, providing more precise repository synchronization reporting.

Review Change Stack

The smoke run on issue #60 surfaced an inconsistency between the
issue title and the body. Title (correct): "Upstream sync: 1521 new
commits in ECC since 9db9867". Body (wrong): "has **250** commit(s)
ahead of the recorded baseline", and the details summary said
"250 total, showing first 50".

Root cause: the GitHub compare endpoint caps `commits[]` at 250 per
response regardless of the true delta. `formatIssueBody` used
`commits.length` for both the intro and the details summary, so any
delta above 250 silently displays as 250. The title was already
correct because it pulls from `compare.ahead_by`.

Fix:
- Add required `totalCount` param to `formatIssueBody` and use it for
  the intro ("has N commit(s) ahead"), the details summary
  ("showing first X of N"), and the truncation footer
  ("… and (N - shown) more").
- Pass `compare.ahead_by` from `buildIssueContent` in the entry
  script.

Tests (+3, 33 total in this file):
- API-cap case (totalCount=1521, commits.length=250): asserts the
  body never mentions 250 and uses 1521 everywhere.
- Total fits in display case: asserts the simple "Commits (N)"
  summary form and no truncation footer.
- Rejection: negative or non-integer totalCount.
- Existing tests updated to pass totalCount.

Lint clean. 264/264 across the suite (was 261).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 232005ee-6066-4a7f-84be-9cbc48dd6d2f

📥 Commits

Reviewing files that changed from the base of the PR and between d258707 and 2e0c8fb.

📒 Files selected for processing (3)
  • scripts/lib/upstream-drift.js
  • scripts/upstream/check-upstream-drift.js
  • tests/lib/upstream-drift.test.js

Walkthrough

The PR updates upstream drift tracking to use GitHub's authoritative commit count (compare API's ahead_by) instead of the potentially truncated commits array. formatIssueBody now accepts and validates totalCount, uses it for the reported count and omission calculations, and the upstream check script passes compare.ahead_by to the formatter.

Changes

Accurate upstream drift reporting

Layer / File(s) Summary
formatIssueBody contract and validation
scripts/lib/upstream-drift.js
Function signature updated to accept totalCount, JSDoc added, and validation ensures totalCount is a non-negative integer.
Issue body generation using totalCount
scripts/lib/upstream-drift.js
The "ahead by" count and commit rendering now use totalCount instead of commits.length, and truncation messaging is recomputed as totalCount - visible.length when commits are omitted.
Upstream check integration
scripts/upstream/check-upstream-drift.js
The buildIssueContent() call now extracts totalCount from compare.ahead_by and passes it to formatIssueBody, with clarifying comments on API capping behavior.
Test coverage for new behavior
tests/lib/upstream-drift.test.js
Tests added/updated to cover empty commits, API-capped truncation, no-truncation, and validation of totalCount including rejection of non-integer and negative values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Jamkris/everything-gemini-code#58: Directly modifies the same upstream-drift helpers and check script; this PR adds totalCount support to functions introduced or refined in that earlier PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the core fix: changing from commits.length to compare.ahead_by for accurate issue body counts.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-body-count

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

@Jamkris Jamkris merged commit 227a26a into main May 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant