Skip to content

Commit 4ab7f0f

Browse files
authored
Merge pull request #128 from JohnTitor/kitogo/master
Closes #68 Fixes #67
2 parents 55d550e + bdebf13 commit 4ab7f0f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ fn fill_todo(
886886
});
887887
match dirs {
888888
Ok(mut children) => {
889+
if options.require_literal_leading_dot {
890+
children.retain(|x| !x.file_name().unwrap().to_str().unwrap().starts_with("."));
891+
}
889892
children.sort_by(|p1, p2| p2.file_name().cmp(&p1.file_name()));
890893
todo.extend(children.into_iter().map(|x| Ok((x, idx))));
891894

tests/glob-std.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
extern crate glob;
1616
extern crate tempdir;
1717

18-
use glob::glob;
18+
use glob::{glob, glob_with};
1919
use std::env;
2020
use std::fs;
2121
use std::path::PathBuf;
@@ -35,6 +35,10 @@ fn main() {
3535
glob(pattern).unwrap().map(|r| r.unwrap()).collect()
3636
}
3737

38+
fn glob_with_vec(pattern: &str, options: glob::MatchOptions) -> Vec<PathBuf> {
39+
glob_with(pattern, options).unwrap().map(|r| r.unwrap()).collect()
40+
}
41+
3842
let root = TempDir::new("glob-tests");
3943
let root = root.ok().expect("Should have created a temp directory");
4044
assert!(env::set_current_dir(root.path()).is_ok());
@@ -307,6 +311,27 @@ fn main() {
307311
vec!(PathBuf::from("bbb/specials/]"))
308312
);
309313

314+
mk_file("i", true);
315+
mk_file("i/qwe", true);
316+
mk_file("i/qwe/.aaa", false);
317+
mk_file("i/qwe/.bbb", true);
318+
mk_file("i/qwe/.bbb/ccc", false);
319+
mk_file("i/qwe/.bbb/.ddd", false);
320+
mk_file("i/qwe/eee", false);
321+
322+
let options = glob::MatchOptions {
323+
case_sensitive: false,
324+
require_literal_separator: true,
325+
require_literal_leading_dot: true,
326+
};
327+
assert_eq!(glob_with_vec("i/**/*a*", options), Vec::<PathBuf>::new());
328+
assert_eq!(glob_with_vec("i/**/*c*", options), Vec::<PathBuf>::new());
329+
assert_eq!(glob_with_vec("i/**/*d*", options), Vec::<PathBuf>::new());
330+
assert_eq!(
331+
glob_with_vec("i/**/*e*", options),
332+
vec!(PathBuf::from("i/qwe"), PathBuf::from("i/qwe/eee"))
333+
);
334+
310335
if env::consts::FAMILY != "windows" {
311336
assert_eq!(
312337
glob_vec("bbb/specials/[*]"),

0 commit comments

Comments
 (0)