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

Function change_by_sha

atomic-cli/tests/it/git_import_cb9a_test.rs:117–140  ·  view source on GitHub ↗
(
    repo: &atomic_repository::Repository,
    git_sha: &str,
)

Source from the content-addressed store, hash-verified

115}
116
117fn change_by_sha(
118 repo: &atomic_repository::Repository,
119 git_sha: &str,
120) -> atomic_core::change::Change {
121 // The importer records the Git SHA in the acceleration index; the
122 // authoritative lookup here walks the view history and matches the
123 // unhashed provenance, which is exactly what a foreign reader sees.
124 let entries = repo.effective_history(Some("main")).unwrap();
125 let mut found = None;
126 for entry in entries {
127 let change = repo.load_change(&entry.hash).unwrap();
128 let sha = change
129 .unhashed
130 .as_ref()
131 .and_then(|value| value.get("git"))
132 .and_then(|git| git.get("sha"))
133 .and_then(|sha| sha.as_str());
134 if sha == Some(git_sha) {
135 found = Some(change);
136 break;
137 }
138 }
139 found.unwrap_or_else(|| panic!("no imported change for git commit {git_sha}"))
140}
141
142#[test]
143fn incremental_dry_run_leaves_legacy_database_untouched_until_explicit_open() {

Calls 6

effective_historyMethod · 0.80
as_refMethod · 0.80
getMethod · 0.65
unwrapMethod · 0.45
load_changeMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected