mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-08-04 21:52:54 +02:00
ignore/gitignore: skip BOM at start of ignore file
This matches Git's behavior. Fixes #2177, Closes #2782
This commit is contained in:
committed by
Andrew Gallant
parent
57e90533a0
commit
ca88b2fd95
2
crates/ignore/tests/gitignore_skip_bom.gitignore
Normal file
2
crates/ignore/tests/gitignore_skip_bom.gitignore
Normal file
@ -0,0 +1,2 @@
|
||||
ignore/this/path
|
||||
# This file begins with a BOM (U+FEFF)
|
17
crates/ignore/tests/gitignore_skip_bom.rs
Normal file
17
crates/ignore/tests/gitignore_skip_bom.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use ignore::gitignore::GitignoreBuilder;
|
||||
|
||||
const IGNORE_FILE: &'static str = "tests/gitignore_skip_bom.gitignore";
|
||||
|
||||
/// Skip a Byte-Order Mark (BOM) at the beginning of the file, matching Git's
|
||||
/// behavior.
|
||||
///
|
||||
/// Ref: <https://github.com/BurntSushi/ripgrep/issues/2177>
|
||||
#[test]
|
||||
fn gitignore_skip_bom() {
|
||||
let mut builder = GitignoreBuilder::new("ROOT");
|
||||
let error = builder.add(IGNORE_FILE);
|
||||
assert!(error.is_none(), "failed to open gitignore file");
|
||||
let g = builder.build().unwrap();
|
||||
|
||||
assert!(g.matched("ignore/this/path", false).is_ignore());
|
||||
}
|
Reference in New Issue
Block a user