Show More
@@ -388,6 +388,15 b" impl<'a> Matcher for PatternMatcher<'a> " | |||
|
388 | 388 | /// assert_eq!(matcher.matches(HgPath::new(b"this should work")), true); |
|
389 | 389 | /// assert_eq!(matcher.matches(HgPath::new(b"this also")), true); |
|
390 | 390 | /// assert_eq!(matcher.matches(HgPath::new(b"but not this")), false); |
|
391 | /// /// | |
|
392 | /// let ignore_patterns = | |
|
393 | /// vec![IgnorePattern::new(PatternSyntax::RootFiles, b"dir/subdir", Path::new(""))]; | |
|
394 | /// let matcher = IncludeMatcher::new(ignore_patterns).unwrap(); | |
|
395 | /// /// | |
|
396 | /// assert!(!matcher.matches(HgPath::new(b"file"))); | |
|
397 | /// assert!(!matcher.matches(HgPath::new(b"dir/file"))); | |
|
398 | /// assert!(matcher.matches(HgPath::new(b"dir/subdir/file"))); | |
|
399 | /// assert!(!matcher.matches(HgPath::new(b"dir/subdir/subsubdir/file"))); | |
|
391 | 400 | /// ``` |
|
392 | 401 | pub struct IncludeMatcher<'a> { |
|
393 | 402 | patterns: Vec<u8>, |
@@ -951,12 +960,8 b" fn build_match<'a>(" | |||
|
951 | 960 | |
|
952 | 961 | let match_func = move |path: &HgPath| -> bool { |
|
953 | 962 | let path = path.as_bytes(); |
|
954 |
let i = path.iter().r |
|
|
955 | let dir = if let Some(i) = i { | |
|
956 | &path[..*i as usize] | |
|
957 | } else { | |
|
958 | b"." | |
|
959 | }; | |
|
963 | let i = path.iter().rposition(|a| *a == b'/'); | |
|
964 | let dir = if let Some(i) = i { &path[..i] } else { b"." }; | |
|
960 | 965 | dirs.contains(dir) |
|
961 | 966 | }; |
|
962 | 967 | match_funcs.push(Box::new(match_func)); |
General Comments 0
You need to be logged in to leave comments.
Login now