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

Function collect_top_level_locks

atomic-cli/src/commands/git/observation.rs:1234–1261  ·  view source on GitHub ↗
(
    directory: &Path,
    locks: &mut BTreeSet<PathBuf>,
)

Source from the content-addressed store, hash-verified

1232}
1233
1234fn collect_top_level_locks(
1235 directory: &Path,
1236 locks: &mut BTreeSet<PathBuf>,
1237) -> Result<(), ObservationError> {
1238 let entries = match fs::read_dir(directory) {
1239 Ok(entries) => entries,
1240 Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(()),
1241 Err(error) => {
1242 return Err(ObservationError::new(format!(
1243 "cannot inspect Git administrative directory '{}': {error}",
1244 directory.display()
1245 )));
1246 }
1247 };
1248 for entry in entries {
1249 let entry = entry.map_err(|error| {
1250 ObservationError::new(format!(
1251 "cannot inspect entry under '{}': {error}",
1252 directory.display()
1253 ))
1254 })?;
1255 let path = entry.path();
1256 if path.extension().and_then(|extension| extension.to_str()) == Some("lock") {
1257 locks.insert(path);
1258 }
1259 }
1260 Ok(())
1261}
1262
1263fn collect_locks_recursive(
1264 directory: &Path,

Callers 1

observe_locksFunction · 0.70

Calls 4

extensionMethod · 0.80
kindMethod · 0.45
pathMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected