feat: skip generated git-tracked files during linting#305
Open
zeitlinger wants to merge 4 commits into
Open
Conversation
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>
Contributor
There was a problem hiding this comment.
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-generatedand 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
.gitattributesfor 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.
| 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 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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.gitattributesinstead of Flint-only config when possibleWhy
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 testmise run lint:fix