summaryrefslogtreecommitdiffstats
path: root/ignore
diff options
context:
space:
mode:
authorAwad Mackie <firesock.serwalek@gmail.com>2018-11-25 21:17:18 +0000
committerAndrew Gallant <jamslam@gmail.com>2019-01-23 20:08:48 -0500
commit44a9e377371006f01f2e425fbf8d49e43bc14a9b (patch)
tree5cd25a0b40fa78b0bcc5d8a25f417ae12ae079d2 /ignore
parent8fd05caceefb9fe0f7c43cf9ffce97f48ea97395 (diff)
ignore/types: add method for retrieving file type definition
Fixes #1116, Closes #1120
Diffstat (limited to 'ignore')
-rw-r--r--ignore/src/types.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/ignore/src/types.rs b/ignore/src/types.rs
index 74c27c46..d7a1fc74 100644
--- a/ignore/src/types.rs
+++ b/ignore/src/types.rs
@@ -350,6 +350,18 @@ impl<'a> Glob<'a> {
fn unmatched() -> Glob<'a> {
Glob(GlobInner::UnmatchedIgnore)
}
+
+ /// Return the file type defintion that matched, if one exists. A file type
+ /// definition always exists when a specific definition matches a file
+ /// path.
+ pub fn file_type_def(&self) -> Option<&FileTypeDef> {
+ match self {
+ Glob(GlobInner::UnmatchedIgnore) => None,
+ Glob(GlobInner::Matched { def, .. }) => {
+ Some(def)
+ },
+ }
+ }
}
/// A single file type definition.