(git_repo: &GitRepository, target_ref: &str)
| 517 | |
| 518 | impl 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(); |
nothing calls this directly
no test coverage detected