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

Method capture

atomic-cli/src/commands/git/shadow.rs:519–535  ·  view source on GitHub ↗
(git_repo: &GitRepository, target_ref: &str)

Source from the content-addressed store, hash-verified

517
518impl GitSwitchSnapshot {
519 fn capture(git_repo: &GitRepository, target_ref: &str) -> CliResult<Self> {
520 let index_path = git_repo.path().join("index");
521 let index = match std::fs::read(&index_path) {
522 Ok(bytes) => Some(bytes),
523 Err(error) if error.kind() == std::io::ErrorKind::NotFound => None,
524 Err(error) => {
525 return Err(git_error(format!(
526 "cannot snapshot Git index before shadow switch: {error}"
527 )))
528 }
529 };
530 Ok(Self {
531 head: snapshot_reference(git_repo, "HEAD")?,
532 target: snapshot_reference(git_repo, target_ref)?,
533 index,
534 })
535 }
536
537 fn restore(&self, git_repo: &GitRepository, target_ref: &str) -> Vec<String> {
538 let mut failures = Vec::new();

Callers

nothing calls this directly

Calls 5

snapshot_referenceFunction · 0.85
git_errorFunction · 0.70
readFunction · 0.50
pathMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected