Check whether a relative path should be ignored based on `.dockerignore` patterns. Uses a simple glob-matching approach: patterns are matched against the full relative path. A leading `/` anchors to the context root. The last matching pattern wins (negation patterns re-include files).
(relative_path: &str, is_dir: bool, patterns: &[IgnorePattern])
| 368 | /// full relative path. A leading `/` anchors to the context root. The last |
| 369 | /// matching pattern wins (negation patterns re-include files). |
| 370 | fn is_ignored(relative_path: &str, is_dir: bool, patterns: &[IgnorePattern]) -> bool { |
| 371 | let mut ignored = false; |
| 372 | |
| 373 | for pat in patterns { |
| 374 | let pattern = pat.pattern.trim_start_matches('/'); |
| 375 | |
| 376 | // Check if the pattern matches. |
| 377 | let matches = glob_match(pattern, relative_path, is_dir); |
| 378 | |
| 379 | if matches { |
| 380 | ignored = !pat.negated; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | ignored |
| 385 | } |
| 386 | |
| 387 | /// Simple glob matching supporting `*`, `**`, and `?`. |
| 388 | /// |
no test coverage detected