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

Function publish_binding_for

atomic-cli/tests/it/git_binding_cb6c_test.rs:134–217  ·  view source on GitHub ↗

Publish a signed binding for `commit` (tree `tree_hex`) over the view's effective closure with the pack attached — the repository-level contract of `git shim binding publish`.

(root: &Path, home: &Path, commit: &git2::Oid, tree_hex: &str)

Source from the content-addressed store, hash-verified

132/// effective closure with the pack attached — the repository-level contract of
133/// `git shim binding publish`.
134fn publish_binding_for(root: &Path, home: &Path, commit: &git2::Oid, tree_hex: &str) -> String {
135 let _ = home;
136 let repo = atomic_repository::Repository::open(root).expect("open atomic");
137 let working_copy = repo.require_working_copy_id().expect("working copy");
138 let view = repo.desired_view_name(working_copy).expect("desired view");
139 let git = git2::Repository::open(root).expect("open git");
140 let identity = repo.view_identity(&view).expect("view identity");
141 let history: Vec<atomic_core::Hash> = repo
142 .effective_history(Some(&view))
143 .expect("history")
144 .iter()
145 .map(|entry| entry.hash)
146 .collect();
147 // The whole recorded closure: native changes without unhashed sections.
148 let ordered: Vec<atomic_core::Hash> = history;
149 let mut merkle = atomic_core::types::Merkle::ZERO;
150 for hash in &ordered {
151 merkle = merkle.next(hash);
152 }
153 let raw_commit = git
154 .odb()
155 .expect("odb")
156 .read(*commit)
157 .expect("read commit")
158 .data()
159 .to_vec();
160 let parents: Vec<atomic_repository::git_binding::GitOid> = git
161 .find_commit(*commit)
162 .expect("commit")
163 .parent_ids()
164 .map(|oid| {
165 atomic_repository::git_binding::GitOid::from_hex(&oid.to_string()).expect("parent")
166 })
167 .collect();
168 let mut secret = [0u8; 32];
169 for (index, byte) in secret.iter_mut().enumerate() {
170 *byte = 0x60u8.wrapping_add((index as u8) * 5 + 3);
171 }
172 let signer = atomic_identity::keypair::KeyPair::from_secret_key(
173 atomic_identity::keypair::SecretKey::from_bytes(&secret),
174 );
175 let operation = {
176 use atomic_repository::OperationHeadState;
177 match repo
178 .operation_log(
179 atomic_core::operation::OperationScope::WorkingCopy(working_copy),
180 Some(1),
181 false,
182 )
183 .expect("op log")
184 .head_state
185 {
186 OperationHeadState::Single(head) => head,
187 other => panic!("expected a single operation head, got {other:?}"),
188 }
189 };
190 let mut payload = atomic_repository::git_binding::GitStateBindingPayload {
191 version: atomic_repository::git_binding::BINDING_VERSION,

Calls 15

openFunction · 0.85
WorkingCopyInterface · 0.85
changes_pack_forFunction · 0.85
desired_view_nameMethod · 0.80
view_identityMethod · 0.80
effective_historyMethod · 0.80
iter_mutMethod · 0.80
operation_logMethod · 0.80
compute_closure_rootMethod · 0.80
collectMethod · 0.45

Tested by

no test coverage detected