mirror of https://github.com/sharkdp/bat
Merge pull request #2755 from cyqsimon/syntax-mapping-refactor
More extensible syntax mapping mechanismpull/2835/head
commit
db66e4459b
@ -0,0 +1,292 @@
|
||||
use std::{
|
||||
convert::Infallible,
|
||||
env, fs,
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, bail};
|
||||
use indexmap::IndexMap;
|
||||
use itertools::Itertools;
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use serde_with::DeserializeFromStr;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
/// Known mapping targets.
|
||||
///
|
||||
/// Corresponds to `syntax_mapping::MappingTarget`.
|
||||
#[allow(clippy::enum_variant_names)]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, Hash, DeserializeFromStr)]
|
||||
pub enum MappingTarget {
|
||||
MapTo(String),
|
||||
MapToUnknown,
|
||||
MapExtensionToUnknown,
|
||||
}
|
||||
impl FromStr for MappingTarget {
|
||||
type Err = Infallible;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"MappingTarget::MapToUnknown" => Ok(Self::MapToUnknown),
|
||||
"MappingTarget::MapExtensionToUnknown" => Ok(Self::MapExtensionToUnknown),
|
||||
syntax => Ok(Self::MapTo(syntax.into())),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl MappingTarget {
|
||||
fn codegen(&self) -> String {
|
||||
match self {
|
||||
Self::MapTo(syntax) => format!(r###"MappingTarget::MapTo(r#"{syntax}"#)"###),
|
||||
Self::MapToUnknown => "MappingTarget::MapToUnknown".into(),
|
||||
Self::MapExtensionToUnknown => "MappingTarget::MapExtensionToUnknown".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, DeserializeFromStr)]
|
||||
/// A single matcher.
|
||||
///
|
||||
/// Codegen converts this into a `Lazy<Option<GlobMatcher>>`.
|
||||
struct Matcher(Vec<MatcherSegment>);
|
||||
/// Parse a matcher.
|
||||
///
|
||||
/// Note that this implementation is rather strict: it will greedily interpret
|
||||
/// every valid environment variable replacement as such, then immediately
|
||||
/// hard-error if it finds a '$', '{', or '}' anywhere in the remaining text
|
||||
/// segments.
|
||||
///
|
||||
/// The reason for this strictness is I currently cannot think of a valid reason
|
||||
/// why you would ever need '$', '{', or '}' as plaintext in a glob pattern.
|
||||
/// Therefore any such occurrences are likely human errors.
|
||||
///
|
||||
/// If we later discover some edge cases, it's okay to make it more permissive.
|
||||
impl FromStr for Matcher {
|
||||
type Err = anyhow::Error;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
use MatcherSegment as Seg;
|
||||
static VAR_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\$\{([\w\d_]+)\}").unwrap());
|
||||
|
||||
let mut segments = vec![];
|
||||
let mut text_start = 0;
|
||||
for capture in VAR_REGEX.captures_iter(s) {
|
||||
let match_0 = capture.get(0).unwrap();
|
||||
|
||||
// text before this var
|
||||
let text_end = match_0.start();
|
||||
segments.push(Seg::Text(s[text_start..text_end].into()));
|
||||
text_start = match_0.end();
|
||||
|
||||
// this var
|
||||
segments.push(Seg::Env(capture.get(1).unwrap().as_str().into()));
|
||||
}
|
||||
// possible trailing text
|
||||
segments.push(Seg::Text(s[text_start..].into()));
|
||||
|
||||
// cleanup empty text segments
|
||||
let non_empty_segments = segments
|
||||
.into_iter()
|
||||
.filter(|seg| seg.text().map(|t| !t.is_empty()).unwrap_or(true))
|
||||
.collect_vec();
|
||||
|
||||
// sanity check
|
||||
if non_empty_segments
|
||||
.windows(2)
|
||||
.any(|segs| segs[0].is_text() && segs[1].is_text())
|
||||
{
|
||||
unreachable!("Parsed into consecutive text segments: {non_empty_segments:?}");
|
||||
}
|
||||
|
||||
// guard empty case
|
||||
if non_empty_segments.is_empty() {
|
||||
bail!(r#"Parsed an empty matcher: "{s}""#);
|
||||
}
|
||||
|
||||
// guard variable syntax leftover fragments
|
||||
if non_empty_segments
|
||||
.iter()
|
||||
.filter_map(Seg::text)
|
||||
.any(|t| t.contains(['$', '{', '}']))
|
||||
{
|
||||
bail!(r#"Invalid matcher: "{s}""#);
|
||||
}
|
||||
|
||||
Ok(Self(non_empty_segments))
|
||||
}
|
||||
}
|
||||
impl Matcher {
|
||||
fn codegen(&self) -> String {
|
||||
match self.0.len() {
|
||||
0 => unreachable!("0-length matcher should never be created"),
|
||||
// if-let guard would be ideal here
|
||||
// see: https://github.com/rust-lang/rust/issues/51114
|
||||
1 if self.0[0].is_text() => {
|
||||
let s = self.0[0].text().unwrap();
|
||||
format!(r###"Lazy::new(|| Some(build_matcher_fixed(r#"{s}"#)))"###)
|
||||
}
|
||||
// parser logic ensures that this case can only happen when there are dynamic segments
|
||||
_ => {
|
||||
let segs = self.0.iter().map(MatcherSegment::codegen).join(", ");
|
||||
format!(r###"Lazy::new(|| build_matcher_dynamic(&[{segs}]))"###)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A segment in a matcher.
|
||||
///
|
||||
/// Corresponds to `syntax_mapping::MatcherSegment`.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
enum MatcherSegment {
|
||||
Text(String),
|
||||
Env(String),
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
impl MatcherSegment {
|
||||
fn is_text(&self) -> bool {
|
||||
matches!(self, Self::Text(_))
|
||||
}
|
||||
fn is_env(&self) -> bool {
|
||||
matches!(self, Self::Env(_))
|
||||
}
|
||||
fn text(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Text(t) => Some(t),
|
||||
Self::Env(_) => None,
|
||||
}
|
||||
}
|
||||
fn env(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Text(_) => None,
|
||||
Self::Env(t) => Some(t),
|
||||
}
|
||||
}
|
||||
fn codegen(&self) -> String {
|
||||
match self {
|
||||
Self::Text(s) => format!(r###"MatcherSegment::Text(r#"{s}"#)"###),
|
||||
Self::Env(s) => format!(r###"MatcherSegment::Env(r#"{s}"#)"###),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct that models a single .toml file in /src/syntax_mapping/builtins/.
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
struct MappingDefModel {
|
||||
mappings: IndexMap<MappingTarget, Vec<Matcher>>,
|
||||
}
|
||||
impl MappingDefModel {
|
||||
fn into_mapping_list(self) -> MappingList {
|
||||
let list = self
|
||||
.mappings
|
||||
.into_iter()
|
||||
.flat_map(|(target, matchers)| {
|
||||
matchers
|
||||
.into_iter()
|
||||
.map(|matcher| (matcher, target.clone()))
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.collect();
|
||||
MappingList(list)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct MappingList(Vec<(Matcher, MappingTarget)>);
|
||||
impl MappingList {
|
||||
fn codegen(&self) -> String {
|
||||
let array_items: Vec<_> = self
|
||||
.0
|
||||
.iter()
|
||||
.map(|(matcher, target)| {
|
||||
format!("({m}, {t})", m = matcher.codegen(), t = target.codegen())
|
||||
})
|
||||
.collect();
|
||||
let len = array_items.len();
|
||||
|
||||
format!(
|
||||
"/// Generated by build script from /src/syntax_mapping/builtins/.\n\
|
||||
pub(crate) static BUILTIN_MAPPINGS: [(Lazy<Option<GlobMatcher>>, MappingTarget); {len}] = [\n{items}\n];",
|
||||
items = array_items.join(",\n")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the list of paths to all mapping definition files that should be
|
||||
/// included for the current target platform.
|
||||
fn get_def_paths() -> anyhow::Result<Vec<PathBuf>> {
|
||||
let source_subdirs = [
|
||||
"common",
|
||||
#[cfg(target_family = "unix")]
|
||||
"unix-family",
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "macos"
|
||||
))]
|
||||
"bsd-family",
|
||||
#[cfg(target_os = "linux")]
|
||||
"linux",
|
||||
#[cfg(target_os = "macos")]
|
||||
"macos",
|
||||
#[cfg(target_os = "windows")]
|
||||
"windows",
|
||||
];
|
||||
|
||||
let mut toml_paths = vec![];
|
||||
for subdir in source_subdirs {
|
||||
let wd = WalkDir::new(Path::new("src/syntax_mapping/builtins").join(subdir));
|
||||
let paths = wd
|
||||
.into_iter()
|
||||
.filter_map_ok(|entry| {
|
||||
let path = entry.path();
|
||||
(path.is_file() && path.extension().map(|ext| ext == "toml").unwrap_or(false))
|
||||
.then(|| path.to_owned())
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
toml_paths.extend(paths);
|
||||
}
|
||||
|
||||
toml_paths.sort_by_key(|path| {
|
||||
path.file_name()
|
||||
.expect("file name should not terminate in ..")
|
||||
.to_owned()
|
||||
});
|
||||
|
||||
Ok(toml_paths)
|
||||
}
|
||||
|
||||
fn read_all_mappings() -> anyhow::Result<MappingList> {
|
||||
let mut all_mappings = vec![];
|
||||
|
||||
for path in get_def_paths()? {
|
||||
let toml_string = fs::read_to_string(path)?;
|
||||
let mappings = toml::from_str::<MappingDefModel>(&toml_string)?.into_mapping_list();
|
||||
all_mappings.extend(mappings.0);
|
||||
}
|
||||
|
||||
let duplicates = all_mappings
|
||||
.iter()
|
||||
.duplicates_by(|(matcher, _)| matcher)
|
||||
.collect_vec();
|
||||
if !duplicates.is_empty() {
|
||||
bail!("Rules with duplicate matchers found: {duplicates:?}");
|
||||
}
|
||||
|
||||
Ok(MappingList(all_mappings))
|
||||
}
|
||||
|
||||
/// Build the static syntax mappings defined in /src/syntax_mapping/builtins/
|
||||
/// into a .rs source file, which is to be inserted with `include!`.
|
||||
pub fn build_static_mappings() -> anyhow::Result<()> {
|
||||
println!("cargo:rerun-if-changed=src/syntax_mapping/builtins/");
|
||||
|
||||
let mappings = read_all_mappings()?;
|
||||
|
||||
let codegen_path = Path::new(&env::var_os("OUT_DIR").ok_or(anyhow!("OUT_DIR is unset"))?)
|
||||
.join("codegen_static_syntax_mappings.rs");
|
||||
|
||||
fs::write(codegen_path, mappings.codegen())?;
|
||||
|
||||
Ok(())
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
use std::env;
|
||||
|
||||
use globset::GlobMatcher;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::syntax_mapping::{make_glob_matcher, MappingTarget};
|
||||
|
||||
// Static syntax mappings generated from /src/syntax_mapping/builtins/ by the
|
||||
// build script (/build/syntax_mapping.rs).
|
||||
include!(concat!(
|
||||
env!("OUT_DIR"),
|
||||
"/codegen_static_syntax_mappings.rs"
|
||||
));
|
||||
|
||||
// The defined matcher strings are analysed at compile time and converted into
|
||||
// lazily-compiled `GlobMatcher`s. This is so that the string searches are moved
|
||||
// from run time to compile time, thus improving startup performance.
|
||||
//
|
||||
// To any future maintainer (including possibly myself) wondering why there is
|
||||
// not a `BuiltinMatcher` enum that looks like this:
|
||||
//
|
||||
// ```
|
||||
// enum BuiltinMatcher {
|
||||
// Fixed(&'static str),
|
||||
// Dynamic(Lazy<Option<String>>),
|
||||
// }
|
||||
// ```
|
||||
//
|
||||
// Because there was. I tried it and threw it out.
|
||||
//
|
||||
// Naively looking at the problem from a distance, this may seem like a good
|
||||
// design (strongly typed etc. etc.). It would also save on compiled size by
|
||||
// extracting out common behaviour into functions. But while actually
|
||||
// implementing the lazy matcher compilation logic, I realised that it's most
|
||||
// convenient for `BUILTIN_MAPPINGS` to have the following type:
|
||||
//
|
||||
// `[(Lazy<Option<GlobMatcher>>, MappingTarget); N]`
|
||||
//
|
||||
// The benefit for this is that operations like listing all builtin mappings
|
||||
// would be effectively memoised. The caller would not have to compile another
|
||||
// `GlobMatcher` for rules that they have previously visited.
|
||||
//
|
||||
// Unfortunately, this means we are going to have to store a distinct closure
|
||||
// for each rule anyway, which makes a `BuiltinMatcher` enum a pointless layer
|
||||
// of indirection.
|
||||
//
|
||||
// In the current implementation, the closure within each generated rule simply
|
||||
// calls either `build_matcher_fixed` or `build_matcher_dynamic`, depending on
|
||||
// whether the defined matcher contains dynamic segments or not.
|
||||
|
||||
/// Compile a fixed glob string into a glob matcher.
|
||||
///
|
||||
/// A failure to compile is a fatal error.
|
||||
///
|
||||
/// Used internally by `Lazy<Option<GlobMatcher>>`'s lazy evaluation closure.
|
||||
fn build_matcher_fixed(from: &str) -> GlobMatcher {
|
||||
make_glob_matcher(from).expect("A builtin fixed glob matcher failed to compile")
|
||||
}
|
||||
|
||||
/// Join a list of matcher segments to create a glob string, replacing all
|
||||
/// environment variables, then compile to a glob matcher.
|
||||
///
|
||||
/// Returns `None` if any replacement fails, or if the joined glob string fails
|
||||
/// to compile.
|
||||
///
|
||||
/// Used internally by `Lazy<Option<GlobMatcher>>`'s lazy evaluation closure.
|
||||
fn build_matcher_dynamic(segs: &[MatcherSegment]) -> Option<GlobMatcher> {
|
||||
// join segments
|
||||
let mut buf = String::new();
|
||||
for seg in segs {
|
||||
match seg {
|
||||
MatcherSegment::Text(s) => buf.push_str(s),
|
||||
MatcherSegment::Env(var) => {
|
||||
let replaced = env::var(var).ok()?;
|
||||
buf.push_str(&replaced);
|
||||
}
|
||||
}
|
||||
}
|
||||
// compile glob matcher
|
||||
let matcher = make_glob_matcher(&buf).ok()?;
|
||||
Some(matcher)
|
||||
}
|
||||
|
||||
/// A segment of a dynamic builtin matcher.
|
||||
///
|
||||
/// Used internally by `Lazy<Option<GlobMatcher>>`'s lazy evaluation closure.
|
||||
#[derive(Clone, Debug)]
|
||||
enum MatcherSegment {
|
||||
Text(&'static str),
|
||||
Env(&'static str),
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
# `/src/syntax_mapping/builtins`
|
||||
|
||||
The files in this directory define path/name-based syntax mappings, which amend
|
||||
and take precedence over the extension/content-based syntax mappings provided by
|
||||
[syntect](https://github.com/trishume/syntect).
|
||||
|
||||
## File organisation
|
||||
|
||||
Each TOML file should describe the syntax mappings of a single application, or
|
||||
otherwise a set of logically-related rules.
|
||||
|
||||
What defines "a single application" here is deliberately vague, since the
|
||||
file-splitting is purely for maintainability reasons. (Technically, we could
|
||||
just as well use a single TOML file.) So just use common sense.
|
||||
|
||||
TOML files should reside in the corresponding subdirectory of the platform(s)
|
||||
that they intend to target. At compile time, the build script will go through
|
||||
each subdirectory that is applicable to the compilation target, collect the
|
||||
syntax mappings defined by all TOML files, and embed them into the binary.
|
||||
|
||||
## File syntax
|
||||
|
||||
Each TOML file should contain a single section named `mappings`, with each of
|
||||
its keys being a language identifier (first column of `bat -L`; also referred to
|
||||
as "target").
|
||||
|
||||
The value of each key should be an array of strings, with each item being a glob
|
||||
matcher. We will call each of these items a "rule".
|
||||
|
||||
For example, if `foo-application` uses both TOML and YAML configuration files,
|
||||
we could write something like this:
|
||||
|
||||
```toml
|
||||
# 30-foo-application.toml
|
||||
[mappings]
|
||||
"TOML" = [
|
||||
# rules for TOML syntax go here
|
||||
"/usr/share/foo-application/toml-config/*.conf",
|
||||
"/etc/foo-application/toml-config/*.conf",
|
||||
]
|
||||
"YAML" = [
|
||||
# rules for YAML syntax go here
|
||||
# ...
|
||||
]
|
||||
```
|
||||
|
||||
### Dynamic environment variable replacement
|
||||
|
||||
In additional to the standard glob matcher syntax, rules also support dynamic
|
||||
replacement of environment variables at runtime. This allows us to concisely
|
||||
handle things like [XDG](https://specifications.freedesktop.org/basedir-spec/latest/).
|
||||
|
||||
All environment variables intended to be replaced at runtime must be enclosed in
|
||||
`${}`, for example `"/foo/*/${YOUR_ENV}-suffix/*.log"`. Note that this is the
|
||||
**only** admissible syntax; other variable substitution syntaxes are not
|
||||
supported and will either cause a compile time error, or be treated as plain
|
||||
text.
|
||||
|
||||
For example, if `foo-application` also supports per-user configuration files, we
|
||||
could write something like this:
|
||||
|
||||
```toml
|
||||
# 30-foo-application.toml
|
||||
[mappings]
|
||||
"TOML" = [
|
||||
# rules for TOML syntax go here
|
||||
"/usr/share/foo-application/toml-config/*.conf",
|
||||
"/etc/foo-application/toml-config/*.conf",
|
||||
"${XDG_CONFIG_HOME}/foo-application/toml-config/*.conf",
|
||||
"${HOME}/.config/foo-application/toml-config/*.conf",
|
||||
]
|
||||
"YAML" = [
|
||||
# rules for YAML syntax go here
|
||||
# ...
|
||||
]
|
||||
```
|
||||
|
||||
If any environment variable replacement in a rule fails (for example when a
|
||||
variable is unset), or if the glob string after replacements is invalid, the
|
||||
entire rule will be ignored.
|
||||
|
||||
### Explicitly mapping to unknown
|
||||
|
||||
Sometimes it may be necessary to "unset" a particular syntect mapping - perhaps
|
||||
a syntax's matching rules are "too greedy", and is claiming files that it should
|
||||
not. In this case, there are two special identifiers:
|
||||
`MappingTarget::MapToUnknown` and `MappingTarget::MapExtensionToUnknown`
|
||||
(corresponding to the two variants of the `syntax_mapping::MappingTarget` enum).
|
||||
|
||||
An example of this would be `*.conf` files in general. So we may write something
|
||||
like this:
|
||||
|
||||
```toml
|
||||
# 99-unset-ambiguous-extensions.toml
|
||||
[mappings]
|
||||
"MappingTarget::MapExtensionToUnknown" = [
|
||||
"*.conf",
|
||||
]
|
||||
```
|
||||
|
||||
## Ordering
|
||||
|
||||
At compile time, all TOML files applicable to the target are processed in
|
||||
lexicographical filename order. So `00-foo.toml` takes precedence over
|
||||
`10-bar.toml`, which takes precedence over `20-baz.toml`, and so on. Note that
|
||||
**only** the filenames of the TOML files are taken into account; the
|
||||
subdirectories they are placed in have no influence on ordering.
|
||||
|
||||
This behaviour can be occasionally useful for creating high/low priority rules,
|
||||
such as in the aforementioned example of explicitly mapping `*.conf` files to
|
||||
unknown. Generally this should not be much of a concern though, since rules
|
||||
should be written as specifically as possible for each application.
|
||||
|
||||
Rules within each TOML file are processed (and therefore matched) in the order
|
||||
in which they are defined. At runtime, the syntax selection algorithm will
|
||||
short-circuit and return the target of the first matching rule.
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Bourne Again Shell (bash)" = ["/etc/os-release", "/var/run/os-release"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Apache Conf" = ["httpd.conf"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Bourne Again Shell (bash)" = ["**/bat/config"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Dockerfile" = ["Containerfile"]
|
@ -0,0 +1,6 @@
|
||||
[mappings]
|
||||
"C++" = [
|
||||
# probably better than the default Objective C mapping #877
|
||||
"*.h",
|
||||
]
|
||||
"YAML" = [".clang-format"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"F#" = ["*.fs"]
|
@ -0,0 +1,10 @@
|
||||
# Global git config files rooted in `$XDG_CONFIG_HOME/git/` or `$HOME/.config/git/`
|
||||
# See e.g. https://git-scm.com/docs/git-config#FILES
|
||||
|
||||
[mappings]
|
||||
"Git Config" = ["${XDG_CONFIG_HOME}/git/config", "${HOME}/.config/git/config"]
|
||||
"Git Ignore" = ["${XDG_CONFIG_HOME}/git/ignore", "${HOME}/.config/git/ignore"]
|
||||
"Git Attributes" = [
|
||||
"${XDG_CONFIG_HOME}/git/attributes",
|
||||
"${HOME}/.config/git/attributes",
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
# JSON Lines is a simple variation of JSON #2535
|
||||
[mappings]
|
||||
"JSON" = ["*.jsonl"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"nginx" = ["nginx.conf", "mime.types"]
|
@ -0,0 +1,3 @@
|
||||
[mappings]
|
||||
# See #2151, https://nmap.org/book/nse-language.html
|
||||
"Lua" = ["*.nse"]
|
@ -0,0 +1,3 @@
|
||||
# 1515
|
||||
[mappings]
|
||||
"JavaScript (Babel)" = ["*.pac"]
|
@ -0,0 +1,3 @@
|
||||
# Rusty Object Notation #2427
|
||||
[mappings]
|
||||
"Rust" = ["*.ron"]
|
@ -0,0 +1,3 @@
|
||||
# SARIF is a format for reporting static analysis results #2695
|
||||
[mappings]
|
||||
"JSON" = ["*.sarif"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"SSH Config" = ["**/.ssh/config"]
|
@ -0,0 +1,5 @@
|
||||
[mappings]
|
||||
"MappingTarget::MapExtensionToUnknown" = [
|
||||
# common extension used for all kinds of formats
|
||||
"*.conf",
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
[mappings]
|
||||
"MappingTarget::MapToUnknown" = [
|
||||
# "NAnt Build File" should only match *.build files, not files named "build"
|
||||
"build",
|
||||
# "bin/rails" scripts in a Ruby project misidentified as HTML (Rails) #1008
|
||||
"rails",
|
||||
]
|
@ -0,0 +1,7 @@
|
||||
[mappings]
|
||||
"Bourne Again Shell (bash)" = [
|
||||
"/etc/os-release",
|
||||
"/usr/lib/os-release",
|
||||
"/etc/initrd-release",
|
||||
"/usr/lib/extension-release.d/extension-release.*",
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
[mappings]
|
||||
# pacman hooks
|
||||
"INI" = ["/usr/share/libalpm/hooks/*.hook", "/etc/pacman.d/hooks/*.hook"]
|
@ -0,0 +1,21 @@
|
||||
[mappings]
|
||||
"INI" = [
|
||||
"**/systemd/**/*.conf",
|
||||
"**/systemd/**/*.example",
|
||||
"*.automount",
|
||||
"*.device",
|
||||
"*.dnssd",
|
||||
"*.link",
|
||||
"*.mount",
|
||||
"*.netdev",
|
||||
"*.network",
|
||||
"*.nspawn",
|
||||
"*.path",
|
||||
"*.service",
|
||||
"*.scope",
|
||||
"*.slice",
|
||||
"*.socket",
|
||||
"*.swap",
|
||||
"*.target",
|
||||
"*.timer",
|
||||
]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Apache Conf" = ["/etc/apache2/**/*.conf", "/etc/apache2/sites-*/**/*"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"YAML" = ["fish_history"]
|
@ -0,0 +1,3 @@
|
||||
# KornShell is backward-compatible with the Bourne shell #2633
|
||||
[mappings]
|
||||
"Bourne Again Shell (bash)" = ["*.ksh"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"Email" = ["/var/spool/mail/*", "/var/mail/*"]
|
@ -0,0 +1,2 @@
|
||||
[mappings]
|
||||
"nginx" = ["/etc/nginx/**/*.conf", "/etc/nginx/sites-*/**/*"]
|
@ -0,0 +1,5 @@
|
||||
[mappings]
|
||||
"Bourne Again Shell (bash)" = [
|
||||
# used by lots of shells
|
||||
"/etc/profile",
|
||||
]
|
@ -0,0 +1,3 @@
|
||||
FROM docker.io/alpine:latest
|
||||
COPY foo /root/bar
|
||||
RUN sleep 60
|
@ -0,0 +1,3 @@
|
||||
FROM docker.io/alpine:latest
|
||||
COPY foo /root/bar
|
||||
RUN sleep 60
|
Loading…
Reference in New Issue