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

Function observe_git

atomic-cli/src/commands/git/observation.rs:509–530  ·  view source on GitHub ↗

Observe Git at `root` without modifying Git, Atomic, or the working tree.

(root: &Path)

Source from the content-addressed store, hash-verified

507
508/// Observe Git at `root` without modifying Git, Atomic, or the working tree.
509pub fn observe_git(root: &Path) -> Result<GitObservation, ObservationError> {
510 let resolved_root = resolve_path(root, root)?;
511 let git_marker_exists = fs::symlink_metadata(root.join(".git")).is_ok();
512 let repository = match GitRepository::open(root) {
513 Ok(repository) => repository,
514 Err(error) if error.code() == ErrorCode::NotFound && !git_marker_exists => {
515 return Ok(GitObservation::NoGit {
516 root: resolved_root,
517 });
518 }
519 Err(error) => {
520 return Err(ObservationError::new(format!(
521 "cannot read Git repository at '{}': {error}",
522 root.display()
523 )));
524 }
525 };
526
527 observe_open_repository(root, &repository)
528 .map(Box::new)
529 .map(GitObservation::Repository)
530}
531
532/// Observe an already-open repository. This helper is also used by the shim
533/// to share HEAD interpretation without changing its mutating reconcile path.

Callers 11

print_forensic_statusFunction · 0.85
guard_working_copyFunction · 0.85
git_hook_contextFunction · 0.85
run_deferred_observationFunction · 0.85
repository_observationFunction · 0.85
observeMethod · 0.85
inspect_dispatchersFunction · 0.85

Calls 4

resolve_pathFunction · 0.85
openFunction · 0.85
observe_open_repositoryFunction · 0.85
codeMethod · 0.45

Tested by 1