Skip to content

[Diff Viewer] Honor .gitattributes linguist-generated attribute #139

@pedropaulovc

Description

@pedropaulovc

Description

CodjiFlo should respect the .gitattributes linguist-generated attribute to identify and handle auto-generated files in pull request diffs. GitHub uses this convention to mark files like lock files, compiled assets, and generated code that are typically collapsed in their PR diff view.

Motivation

Generated files often clutter the code review experience:

  • Lock files (package-lock.json, yarn.lock, etc.)
  • Compiled/minified output (.min.js, compiled CSS, etc.)
  • Generated code (protobuf files, API client code, etc.)
  • Build artifacts

By honoring linguist-generated, CodjiFlo can reduce cognitive load during code reviews by de-emphasizing these files, matching GitHub's UX behavior and improving the focus on actual code changes.

Proposed Solution

  1. Parse .gitattributes: Read and parse the .gitattributes file from the PR's base commit to identify files marked with linguist-generated=true
  2. Mark Generated Files: Add metadata to identified generated files in the file list
  3. Display Treatment:
    • Collapse generated files by default in the file explorer
    • Visually de-emphasize them (e.g., reduced opacity, italic styling, or distinct badge)
    • Optionally exclude from diff statistics (insertion/deletion counts)
  4. User Control: Allow users to toggle visibility/expansion of generated files if needed

Use Case

When reviewing a PR that updates dependencies, the lock file changes dominate the diff. With this feature:

  • Generated file is collapsed by default
  • Real code changes are immediately visible
  • User can expand if they need to review the generated file

Acceptance Criteria

  • .gitattributes file is read and parsed
  • Files matching linguist-generated patterns are identified
  • Generated files are visually distinct and collapsed in file list
  • Feature gracefully handles repos without .gitattributes
  • E2E tests validate the feature with mock .gitattributes data

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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