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

Function collect_locks_recursive

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

Source from the content-addressed store, hash-verified

1261}
1262
1263fn collect_locks_recursive(
1264 directory: &Path,
1265 locks: &mut BTreeSet<PathBuf>,
1266) -> Result<(), ObservationError> {
1267 let entries = match fs::read_dir(directory) {
1268 Ok(entries) => entries,
1269 Err(error) if error.kind() == io::ErrorKind::NotFound => return Ok(()),
1270 Err(error) => {
1271 return Err(ObservationError::new(format!(
1272 "cannot inspect Git refs directory '{}': {error}",
1273 directory.display()
1274 )));
1275 }
1276 };
1277 for entry in entries {
1278 let entry = entry.map_err(|error| {
1279 ObservationError::new(format!(
1280 "cannot inspect entry under '{}': {error}",
1281 directory.display()
1282 ))
1283 })?;
1284 let file_type = entry.file_type().map_err(|error| {
1285 ObservationError::new(format!(
1286 "cannot inspect Git administrative path '{}': {error}",
1287 entry.path().display()
1288 ))
1289 })?;
1290 let path = entry.path();
1291 if file_type.is_dir() {
1292 collect_locks_recursive(&path, locks)?;
1293 } else if path.extension().and_then(|extension| extension.to_str()) == Some("lock") {
1294 locks.insert(path);
1295 }
1296 }
1297 Ok(())
1298}
1299
1300fn observe_operation(
1301 repository: &GitRepository,

Callers 1

observe_locksFunction · 0.85

Calls 5

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

Tested by

no test coverage detected