Skip to content

feat: skip generated git-tracked files during linting#305

Open
zeitlinger wants to merge 4 commits into
mainfrom
skip-generated-git-tracked-files
Open

feat: skip generated git-tracked files during linting#305
zeitlinger wants to merge 4 commits into
mainfrom
skip-generated-git-tracked-files

Conversation

@zeitlinger
Copy link
Copy Markdown
Member

Summary

  • skip lint targets that are marked as generated in git attributes
  • keep Flint scoped to tracked files and preserve Flint-managed built-in excludes
  • document that generated files should be marked in .gitattributes instead of Flint-only config when possible

Why

Generated files should not be part of ordinary lint runs, and storing that intent in git attributes lets GitHub and other tooling reuse the same metadata.

Root cause

Flint already limited full runs to git ls-files, but generic lint filtering did not consult git attributes for generated files, so tracked generated files could still be linted unless they were excluded in Flint-specific config.

Validation

  • cargo test
  • mise run lint:fix

Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Copilot AI review requested due to automatic review settings May 26, 2026 14:57
@zeitlinger zeitlinger requested a review from a team as a code owner May 26, 2026 14:58
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

This PR updates Flint’s file selection so that tracked files marked as generated via git attributes (specifically linguist-generated in .gitattributes) are excluded from generic linting runs, and documents the recommended exclusion approaches.

Changes:

  • Teach file filtering to consult git check-attr linguist-generated and skip generated tracked files.
  • Propagate the new Result-returning filter behavior through callers and add tests for generated-file skipping.
  • Update README/CLI docs and internal design notes to recommend .gitattributes for generated-file exclusions.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/files.rs Adds git check-attr-based generated-file filtering and expands tests accordingly.
README.md Documents tracked-file scoping and recommends .gitattributes linguist-generated for generated files.
docs/cli.md Clarifies changed/full run scoping to tracked files and documents generated-file skipping behavior.
.github/agents/knowledge/design.md Updates design notes to reflect shared generated exclusions via .gitattributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/files.rs
for chunk in fields.chunks_exact(3) {
let path = String::from_utf8_lossy(chunk[0]);
let info = String::from_utf8_lossy(chunk[2]);
if info == "set" {
Comment thread src/files.rs
Comment on lines +182 to 188
let generated = generated_paths(project_root, &names)?;

Ok(names
.into_iter()
.filter(|name| !BUILTIN_EXCLUDES.contains(&name.as_str()))
.filter(|name| !generated.contains(name))
.filter(|name| !exclude.is_match(name))
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