File tree Expand file tree Collapse file tree 5 files changed +120
-4
lines changed
snapshots/main_cases_vcs_ignored_files
biome_service/src/workspace Expand file tree Collapse file tree 5 files changed +120
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @biomejs/biome " : minor
3
+ ---
4
+
5
+ Fixed [ #6646 ] ( https://github.com/biomejs/biome/issues/6646 ) : ` .gitignore ` files
6
+ are now picked up even when running Biome from a nested directory, or when the
7
+ ignore file itself is ignored through ` files.includes ` .
Original file line number Diff line number Diff line change @@ -190,3 +190,43 @@ fn ignores_file_inside_directory() {
190
190
result,
191
191
) ) ;
192
192
}
193
+
194
+ #[ test]
195
+ fn use_root_gitignore_when_running_from_subdirectory ( ) {
196
+ let mut fs = TemporaryFs :: new ( "use_root_gitignore_when_running_from_subdirectory" ) ;
197
+ let mut console = BufferConsole :: default ( ) ;
198
+
199
+ fs. create_file ( ".gitignore" , r#"dist/"# ) ;
200
+ fs. create_file (
201
+ "biome.json" ,
202
+ r#"{
203
+ "files": {
204
+ "includes": ["packages/**"]
205
+ },
206
+ "vcs": {
207
+ "enabled": true,
208
+ "clientKind": "git",
209
+ "useIgnoreFile": true
210
+ }
211
+ }"# ,
212
+ ) ;
213
+
214
+ fs. create_file ( "packages/lib/dist/out.js" , r#"foo.call(); bar.call();"# ) ;
215
+ fs. create_file ( "packages/lib/src/in.js" , r#"foo.call(); bar.call();"# ) ;
216
+
217
+ fs. append_to_working_directory ( "packages/lib" ) ;
218
+
219
+ let result = run_cli_with_dyn_fs (
220
+ Box :: new ( fs. create_os ( ) ) ,
221
+ & mut console,
222
+ Args :: from ( [ "format" ] . as_slice ( ) ) ,
223
+ ) ;
224
+
225
+ assert_cli_snapshot ( SnapshotPayload :: new (
226
+ module_path ! ( ) ,
227
+ "use_root_gitignore_when_running_from_subdirectory" ,
228
+ fs. create_mem ( ) ,
229
+ console,
230
+ result,
231
+ ) ) ;
232
+ }
Original file line number Diff line number Diff line change
1
+ -- -
2
+ source : crates / biome_cli / tests / snap_test .rs
3
+ expression : redactor (content )
4
+ -- -
5
+ ## ` biome.json`
6
+
7
+ ` ` ` json
8
+ {
9
+ " files" : {
10
+ " includes" : [" packages/**" ]
11
+ },
12
+ " vcs" : {
13
+ " enabled" : true ,
14
+ " clientKind" : " git" ,
15
+ " useIgnoreFile" : true
16
+ }
17
+ }
18
+ ` ` `
19
+
20
+ ## ` .gitignore`
21
+
22
+ ` ` ` gitignore
23
+ dist/
24
+ ` ` `
25
+
26
+ ## ` packages/lib/dist/out.js`
27
+
28
+ ` ` ` js
29
+ foo.call(); bar.call();
30
+ ` ` `
31
+
32
+ ## ` packages/lib/src/in.js`
33
+
34
+ ` ` ` js
35
+ foo.call(); bar.call();
36
+ ` ` `
37
+
38
+ # Termination Message
39
+
40
+ ` ` ` block
41
+ format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
42
+
43
+ × Some errors were emitted while running checks.
44
+
45
+
46
+
47
+ ` ` `
48
+
49
+ # Emitted Messages
50
+
51
+ ` ` ` block
52
+ src/in.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
53
+
54
+ × Formatter would have printed the following content:
55
+
56
+ 1 │ - foo.call();·bar.call();
57
+ 1 │ + foo.call();
58
+ 2 │ + bar.call();
59
+ 3 │ +
60
+
61
+
62
+ ` ` `
63
+
64
+ ` ` ` block
65
+ Checked 1 file in <TIME >. No fixes applied.
66
+ Found 1 error.
67
+ ```
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ impl BiomePath {
170
170
pub fn is_dependency ( & self ) -> bool {
171
171
self . path
172
172
. components ( )
173
- . any ( |component| component. as_str ( ) == "node_modules" )
173
+ . any ( |component| component. as_str ( ) . as_bytes ( ) == b "node_modules")
174
174
}
175
175
176
176
/// Whether this is a file named `package.json`
Original file line number Diff line number Diff line change @@ -329,12 +329,14 @@ impl TraversalContext for ScanContext<'_> {
329
329
}
330
330
Ok ( PathKind :: File { .. } ) => match & self . scan_kind {
331
331
ScanKind :: KnownFiles | ScanKind :: TargetedKnownFiles { .. } => {
332
- path. is_required_during_scan ( )
333
- && !path. is_dependency ( )
334
- && !self
332
+ if path. is_config ( ) {
333
+ !self
335
334
. workspace
336
335
. projects
337
336
. is_ignored_by_top_level_config ( self . project_key , path)
337
+ } else {
338
+ path. is_ignore ( ) || path. is_manifest ( )
339
+ }
338
340
}
339
341
ScanKind :: Project => {
340
342
if path. is_dependency ( ) {
You can’t perform that action at this time.
0 commit comments