Skip to content

[minor][engg]: exclude comments and blank lines from PR size line count#2978

Open
Copilot wants to merge 2 commits into
devfrom
copilot/update-pipeline-ignore-comments
Open

[minor][engg]: exclude comments and blank lines from PR size line count#2978
Copilot wants to merge 2 commits into
devfrom
copilot/update-pipeline-ignore-comments

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

  • Add countCodeLines(patch, fallback) helper to .github/workflows/pr-size-check-reusable.yml that parses a unified-diff patch and skips blank lines, // single-line comments, and /* … */ multi-line block comments
  • Replace f.additions + f.deletions with countCodeLines in the totalLines sum
  • Update per-file table rows to display comment-stripped line counts instead of raw +additions / -deletions
  • Update the job-summary status label wording to say "code lines" for clarity
  • Cache codeLinesChanged once per included file to avoid re-scanning the same patch multiple times
  • Sort summary table by codeLinesChanged (code lines) instead of raw additions + deletions

@@ -254,6 +254,64 @@ jobs:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request does not update CHANGELOG.md.

Please consider if this change would be noticeable to a partner or user and either update CHANGELOG.md or resolve this conversation.

@ameyapat ameyapat marked this pull request as ready for review April 29, 2026 23:05
@ameyapat ameyapat requested a review from a team as a code owner April 29, 2026 23:05
@ameyapat ameyapat changed the title feat: exclude comments and blank lines from PR size line count [minor][engg]: exclude comments and blank lines from PR size line count Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the PR Size Check reusable workflow to count only “real code” lines changed (excluding blank lines and // / /* */ comment-only lines) when enforcing the max-lines threshold, so cosmetic changes don’t inflate PR size.

Changes:

  • Added a countCodeLines(patch, rawLines) helper to scan GitHub unified diff patches and count only non-comment, non-blank added/removed lines.
  • Switched the overall line-limit calculation from additions + deletions to the helper-derived “code lines” count (with fallback to raw counts when patch is missing).
  • Updated the summary table and status/failure messages to reflect “code lines changed” semantics.

Comment thread .github/workflows/pr-size-check-reusable.yml Outdated
Comment on lines 362 to 365
@@ -306,7 +364,7 @@ jobs:
(a, b) => (b.additions + b.deletions) - (a.additions + a.deletions)
);
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

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

The summary table is now labeled in code lines, but sortedIncluded is still ordered by raw additions + deletions. Impact: the “top N files by changes” table may be misleading (files with many comment/blank-line edits can sort to the top even if they have few counted code lines). Recommendation: sort by the same countCodeLines(...) (or a cached codeLinesChanged) value that you display in the table.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 205fdc5. countCodeLines is now called once per file and the result cached as f.codeLinesChanged. Both the totalLines reduction and the table rows read from that cached value. The summary table sort also now uses codeLinesChanged so the ranking is consistent with what's displayed.

Copilot AI requested a review from ameyapat April 30, 2026 20:58
swasti29 added a commit that referenced this pull request May 2, 2026
Replaces line-prefix heuristics with character-by-character parser
that tracks block-comment state across lines (based on PR #2978).
support, +/- breakdown, and diff-header skipping from #2979.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

3 participants