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

Function exclude_path

atomic-repository/src/repository/ignore_mirror.rs:111–131  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

109}
110
111fn exclude_path(root: &Path) -> Result<std::path::PathBuf, IgnoreMirrorError> {
112 let repository = git2::Repository::discover(root)
113 .map_err(|error| IgnoreMirrorError::GitDirectory(format!("{}: {error}", root.display())))?;
114 // `.git/info/exclude` lives in the common administrative directory so
115 // linked worktrees share one managed block. git2 0.19 does not expose
116 // `commondir()`, so resolve the `commondir` pointer file explicitly.
117 let git_dir = repository.path();
118 let common_dir = match fs::read_to_string(git_dir.join("commondir")) {
119 Ok(pointer) => {
120 let pointer = pointer.trim_end_matches(['\n', '\r']);
121 let absolute = if Path::new(pointer).is_absolute() {
122 std::path::PathBuf::from(pointer)
123 } else {
124 git_dir.join(pointer)
125 };
126 fs::canonicalize(&absolute).unwrap_or(absolute)
127 }
128 Err(_) => git_dir.to_path_buf(),
129 };
130 Ok(common_dir.join("info").join("exclude"))
131}
132
133fn read_exclude_patterns(path: &Path) -> Result<Vec<String>, IgnoreMirrorError> {
134 match fs::read(path) {

Callers 2

check_ignore_policyFunction · 0.85
mirror_ignoresFunction · 0.85

Calls 2

canonicalizeFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected