Skip to content

Add File Exclusion Option to gh pr diff Command #8739

@kalanyuz

Description

@kalanyuz

Describe the feature or problem you’d like to solve

Currently, when reviewing pull requests using the gh pr diff command, users receive the entire diff of the PR without the ability to exclude specific files or directories from the output. This can be overwhelming and inefficient, especially in large PRs where changes to certain files (e.g., auto-generated files, specific directories) may not be relevant to the reviewer's focus.

Proposed solution

Introduce a new option for the gh pr diff command that allows users to specify files or directories to exclude from the diff output. This could follow the syntax similar to .gitignore or support glob patterns for flexibility. For example, adding a --exclude or -e option:

gh pr diff --exclude "generated/*,docs/*"

This feature would benefit CLI users by providing more control over the diff output, allowing for a more focused and effective review process. It would particularly benefit those working in projects with a mix of hand-written and auto-generated code or projects where changes to specific areas are less relevant for certain types of reviews.

Additional context

git diff -- ':![exclusion]' could achieve something like this, but there are many scenarios that git diff is not viable as it'd be difficult to get the commit before the PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLIgh-prrelating to the gh pr commandhelp wantedContributions welcome

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions