MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / from_file

Method from_file

atomic-repository/src/ignore.rs:169–188  ·  view source on GitHub ↗

Load ignore rules from a specific file only. This is useful for testing or when you want to use a custom ignore file. # Arguments `repo_root` - The root directory of the repository `ignore_path` - Path to the ignore file # Returns An `IgnoreRules` instance with patterns from the specified file.

(repo_root: &Path, ignore_path: &Path)

Source from the content-addressed store, hash-verified

167 ///
168 /// An `IgnoreRules` instance with patterns from the specified file.
169 pub fn from_file(repo_root: &Path, ignore_path: &Path) -> IgnoreResult<Self> {
170 let local = if ignore_path.exists() {
171 let mut builder = GitignoreBuilder::new(repo_root);
172 if let Some(err) = builder.add(ignore_path) {
173 return Err(IgnoreError::ParseError {
174 path: ignore_path.display().to_string(),
175 details: err.to_string(),
176 });
177 }
178 builder.build().ok()
179 } else {
180 None
181 };
182
183 Ok(Self {
184 global: None,
185 local,
186 repo_root: repo_root.to_path_buf(),
187 })
188 }
189
190 /// Check if a path should be ignored.
191 ///

Callers

nothing calls this directly

Calls 5

displayMethod · 0.80
existsMethod · 0.45
addMethod · 0.45
okMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected