Skip to content

Add show_patch_table configuration option for PR comments#528

Closed
blimpich wants to merge 1 commit intocodecov:mainfrom
blimpich:blimpich-addShowPatchTableConfig
Closed

Add show_patch_table configuration option for PR comments#528
blimpich wants to merge 1 commit intocodecov:mainfrom
blimpich:blimpich-addShowPatchTableConfig

Conversation

@blimpich
Copy link

@blimpich blimpich commented Oct 9, 2025

Summary

This PR adds a new boolean configuration option show_patch_table under the comment section of codecov.yml that controls whether the patch coverage table is automatically added to PR comments when using the files or tree layout components.

Problem

Currently, when users specify layout: "files" or layout: "tree" in their codecov.yml, the system automatically injects the newfiles section, which displays a "Patch %" table showing patch coverage information. This behavior is hardcoded at lines 57-59 in apps/worker/services/notification/notifiers/mixins/message/sections.py:

# append the `newfiles` section if there is a `files` or `tree` section
if "files" in sections or "tree" in sections:
    sections.append("newfiles")

There is no way for users to disable this automatic injection, even if they only want to see the overall coverage delta per file (the "Coverage Δ" table) without the patch-specific information.

Solution

This PR introduces a new configuration option show_patch_table (defaults to true to maintain backward compatibility) that controls whether the automatic injection occurs.

Changes Made

  1. Schema Update (libs/shared/shared/validation/user_schema.py):

    • Added show_patch_table as a boolean field with default value True
  2. Logic Update (apps/worker/services/notification/notifiers/mixins/message/sections.py):

    • Modified the auto-injection logic to check the show_patch_table setting before adding newfiles

Example Usage

Users can now configure their PR comments to show only the files coverage delta table:

comment:
  layout: "condensed_header, files, condensed_footer"
  show_patch_table: false  # Show only Coverage Δ table, not Patch % table

Use Case

This feature is valuable for teams that:

  • Want concise PR comments focused on overall coverage changes
  • Find the patch coverage table redundant with their existing coverage requirements
  • Prefer to keep PR comments minimal while still showing per-file coverage deltas

Backward Compatibility

By defaulting show_patch_table to true, all existing configurations will continue to work exactly as before. Only users who explicitly set show_patch_table: false will see the new behavior.

Testing

The changes are minimal and focused:

  • The schema validation will automatically handle the new boolean field
  • The logic change is a simple conditional check that defaults to existing behavior
  • No breaking changes to existing functionality

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

This adds a new boolean configuration option `show_patch_table` under the
`comment` section of codecov.yml that controls whether the patch coverage
table is automatically added to PR comments when using the `files` or `tree`
layout components.

By default, `show_patch_table: true` maintains existing behavior where the
`newfiles` section (patch coverage table) is automatically appended when
`files` or `tree` is present in the layout.

Setting `show_patch_table: false` allows users to display only the files
table with coverage delta information without the patch coverage table.

Example usage:
```yaml
comment:
  layout: "files"
  show_patch_table: false  # Show only Coverage Δ table, not Patch % table
```

This resolves the issue where users who want concise PR comments showing
only overall coverage changes per file had no way to hide the automatically
injected patch coverage table.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thomasrockhu-codecov
Copy link
Contributor

@blimpich, thanks for the PR here. Unfortunately we aren't supporting new configurations to our yaml currently and wont plan to in the near future. I would recommend opening an issue next time to get buy in from the team first

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.

2 participants