add_line() — tailwindcss Function Reference
Architecture documentation for the add_line() function in gitignore.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD e13a7ddc_3ca6_4a8a_8782_4f52ab015f25["add_line()"] 714a3a15_03d5_1e35_b535_53da70bce8eb["gitignore.rs"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|defined in| 714a3a15_03d5_1e35_b535_53da70bce8eb aeb4abcb_3f26_f670_bc29_d72a919dc43b["add()"] aeb4abcb_3f26_f670_bc29_d72a919dc43b -->|calls| e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 09f649ce_e64d_3364_c456_c73521ca4c9c["add_str()"] 09f649ce_e64d_3364_c456_c73521ca4c9c -->|calls| e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 f30f6608_5b16_4482_3310_8c414d5a3ef4["is_empty()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| f30f6608_5b16_4482_3310_8c414d5a3ef4 74096334_9903_0d86_90a5_99d1d64eb317["len()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| 74096334_9903_0d86_90a5_99d1d64eb317 9cecb9df_647d_be32_6935_def9a5795e06["has_doublestar_prefix()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| 9cecb9df_647d_be32_6935_def9a5795e06 d10b78b9_84ae_8d07_4478_195fdb0ef854["case_insensitive()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| d10b78b9_84ae_8d07_4478_195fdb0ef854 2c7c93aa_82ba_29ed_8817_00530228ca2b["allow_unclosed_class()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| 2c7c93aa_82ba_29ed_8817_00530228ca2b 088ec752_002a_6e18_595e_6a8f31aa2bc5["build()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| 088ec752_002a_6e18_595e_6a8f31aa2bc5 aeb4abcb_3f26_f670_bc29_d72a919dc43b["add()"] e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 -->|calls| aeb4abcb_3f26_f670_bc29_d72a919dc43b style e13a7ddc_3ca6_4a8a_8782_4f52ab015f25 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/ignore/src/gitignore.rs lines 451–532
pub fn add_line(
&mut self,
from: Option<PathBuf>,
mut line: &str,
) -> Result<&mut GitignoreBuilder, Error> {
#![allow(deprecated)]
if line.starts_with("#") {
return Ok(self);
}
if !line.ends_with("\\ ") {
line = line.trim_right();
}
if line.is_empty() {
return Ok(self);
}
let mut glob = Glob {
from,
original: line.to_string(),
actual: String::new(),
is_whitelist: false,
is_only_dir: false,
};
let mut is_absolute = false;
if line.starts_with("\\!") || line.starts_with("\\#") {
line = &line[1..];
is_absolute = line.chars().nth(0) == Some('/');
} else {
if line.starts_with("!") {
glob.is_whitelist = true;
line = &line[1..];
}
if line.starts_with("/") {
// `man gitignore` says that if a glob starts with a slash,
// then the glob can only match the beginning of a path
// (relative to the location of gitignore). We achieve this by
// simply banning wildcards from matching /.
line = &line[1..];
is_absolute = true;
}
}
// If it ends with a slash, then this should only match directories,
// but the slash should otherwise not be used while globbing.
if line.as_bytes().last() == Some(&b'/') {
glob.is_only_dir = true;
line = &line[..line.len() - 1];
// If the slash was escaped, then remove the escape.
// See: https://github.com/BurntSushi/ripgrep/issues/2236
if line.as_bytes().last() == Some(&b'\\') {
line = &line[..line.len() - 1];
}
}
glob.actual = line.to_string();
// If there is a literal slash, then this is a glob that must match the
// entire path name. Otherwise, we should let it match anywhere, so use
// a **/ prefix.
if !is_absolute && !line.chars().any(|c| c == '/') {
// ... but only if we don't already have a **/ prefix.
if !glob.has_doublestar_prefix() {
glob.actual = format!("**/{}", glob.actual);
}
}
// If the glob ends with `/**`, then we should only match everything
// inside a directory, but not the directory itself. Standard globs
// will match the directory. So we add `/*` to force the issue.
if glob.actual.ends_with("/**") {
glob.actual = format!("{}/*", glob.actual);
}
let parsed = GlobBuilder::new(&glob.actual)
.literal_separator(true)
.case_insensitive(self.case_insensitive)
.backslash_escape(true)
.allow_unclosed_class(self.allow_unclosed_class)
.build()
.map_err(|err| Error::Glob {
glob: Some(glob.original.clone()),
err: err.kind().to_string(),
})?;
self.builder.add(parsed);
self.globs.push(glob);
Ok(self)
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does add_line() do?
add_line() is a function in the tailwindcss codebase, defined in crates/ignore/src/gitignore.rs.
Where is add_line() defined?
add_line() is defined in crates/ignore/src/gitignore.rs at line 451.
What does add_line() call?
add_line() calls 7 function(s): add, allow_unclosed_class, build, case_insensitive, has_doublestar_prefix, is_empty, len.
What calls add_line()?
add_line() is called by 2 function(s): add, add_str.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free