Skip to content

fix(linter): respect .gitignore regardless of if a git repo is initialized#17375

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/update-oxlint-gitignore-reading
Dec 27, 2025
Merged

fix(linter): respect .gitignore regardless of if a git repo is initialized#17375
graphite-app[bot] merged 1 commit intomainfrom
copilot/update-oxlint-gitignore-reading

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

Plan: Enable oxlint to read gitignore without git repo initialization

  • Analyze the issue and understand the problem
  • Add .require_git(false) and .git_ignore(true) to WalkBuilder in walk.rs
  • Create a proper unit test in walk.rs that validates auto-discovery of .gitignore files
  • Verify test fails without the settings and passes with them
  • Remove old integration test that didn't properly test the fix
  • Run all tests to ensure no regressions
  • Verify the fix manually with CLI
  • Fix formatting issues for CI
Original prompt

update oxlint to read from the gitignore even if the git repo has not been initialized


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update oxlint to read from .gitignore without initialization Enable oxlint to read .gitignore without git repository initialization Dec 26, 2025
Copilot AI requested a review from camc314 December 26, 2025 17:34
@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI labels Dec 26, 2025
@camc314 camc314 changed the title Enable oxlint to read .gitignore without git repository initialization fix(linter): respect .gitignore regardless of if a git repo is initialized Dec 26, 2025
@github-actions github-actions bot added the C-bug Category - Bug label Dec 26, 2025
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot if i comment out require_git the tests still pass - is this because we're in the root oxc repo?

comment out the change, write a failing test, that then passes if you un-comment it out

Copy link
Contributor Author

Copilot AI commented Dec 26, 2025

@copilot if i comment out require_git the tests still pass - is this because we're in the root oxc repo?

comment out the change, write a failing test, that then passes if you un-comment it out

You were correct! The initial test was passing even without the changes because it was using explicit .gitignore loading via ignore_path instead of testing auto-discovery.

I've updated the implementation to include both .git_ignore(true) and .require_git(false), and created a proper unit test in walk.rs that:

  • Uses auto-discovery (empty ignore_path) to test the actual feature
  • Fails without the settings (finds both files)
  • Passes with the settings (only finds non-ignored file)

The key insight was that .git_ignore(true) enables auto-discovery of .gitignore files, and .require_git(false) allows this to work without a .git directory. The old test bypassed auto-discovery entirely.

Commit: d32a50a

Copilot AI requested a review from camc314 December 26, 2025 18:10
@camc314
Copy link
Contributor

camc314 commented Dec 26, 2025

@copilot fix CI

Copy link
Contributor Author

Copilot AI commented Dec 26, 2025

@copilot fix CI

Fixed formatting issues in walk.rs. The CI was failing due to trailing whitespace and incorrect comment spacing. Commit: fb72dac

@camc314 camc314 marked this pull request as ready for review December 26, 2025 20:48
Copilot AI review requested due to automatic review settings December 26, 2025 20:48
@camc314 camc314 assigned Boshen, camc314 and Copilot and unassigned camc314 and Copilot Dec 26, 2025
@camc314
Copy link
Contributor

camc314 commented Dec 26, 2025

@Boshen mind taking a quick look?

Copy link
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 enables oxlint to respect .gitignore files even when a Git repository hasn't been initialized (i.e., when there's no .git directory). This resolves unexpected behavior where .gitignore files were only honored in initialized Git repositories.

Key Changes

  • Modified WalkBuilder configuration to explicitly enable .gitignore processing and remove the Git repository requirement
  • Added comprehensive unit test validating .gitignore auto-discovery without .git directory
  • Improved code formatting for the builder chain

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

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 27, 2025
Copy link
Member

Boshen commented Dec 27, 2025

Merge activity

…ialized (#17375)

## Plan: Enable oxlint to read gitignore without git repo initialization

- [x] Analyze the issue and understand the problem
- [x] Add `.require_git(false)` and `.git_ignore(true)` to WalkBuilder in walk.rs
- [x] Create a proper unit test in walk.rs that validates auto-discovery of .gitignore files
- [x] Verify test fails without the settings and passes with them
- [x] Remove old integration test that didn't properly test the fix
- [x] Run all tests to ensure no regressions
- [x] Verify the fix manually with CLI
- [x] Fix formatting issues for CI

<!-- START COPILOT CODING AGENT SUFFIX -->

<!-- START COPILOT ORIGINAL PROMPT -->

<details>

<summary>Original prompt</summary>

> update oxlint to read from the gitignore even if the git repo has not been initialized

</details>

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
@graphite-app graphite-app bot force-pushed the copilot/update-oxlint-gitignore-reading branch from 9c6662e to fec2863 Compare December 27, 2025 04:10
@graphite-app graphite-app bot merged commit fec2863 into main Dec 27, 2025
18 checks passed
@graphite-app graphite-app bot deleted the copilot/update-oxlint-gitignore-reading branch December 27, 2025 04:16
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants