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

Function run_pick

atomic-cli/src/commands/insert.rs:376–416  ·  view source on GitHub ↗

Cherry-pick specific changes.

(repo: &Repository, args: &PickArgs)

Source from the content-addressed store, hash-verified

374
375/// Cherry-pick specific changes.
376fn run_pick(repo: &Repository, args: &PickArgs) -> CliResult<()> {
377 let to_view = args
378 .to_view
379 .clone()
380 .unwrap_or_else(|| repo.current_view().to_string());
381 let is_current_view = to_view == repo.current_view();
382
383 // Parse all change hashes
384 let mut hashes = Vec::new();
385 for change_str in &args.changes {
386 let hash = parse_change_hash(repo, change_str)?;
387 hashes.push(hash);
388 }
389
390 output::print_info(&format!(
391 "Cherry-picking {} change(s) to '{}'...",
392 hashes.len(),
393 to_view
394 ));
395
396 let outcome =
397 repo.cherry_pick(&hashes, "", Some(&to_view))
398 .map_err(|e| CliError::Conflict {
399 description: e.to_string(),
400 })?;
401
402 print_cross_view_outcome(&outcome, false);
403
404 // Update working copy if we inserted into the current view
405 if is_current_view && outcome.changes_applied > 0 {
406 let output_result = repo.materialize().map_err(|e| {
407 CliError::Internal(anyhow::anyhow!("Failed to update working copy: {}", e))
408 })?;
409 output::print_success(&format!(
410 "{} files updated, {} directories",
411 output_result.files_written, output_result.directories_created
412 ));
413 }
414
415 Ok(())
416}
417
418/// Preview what would be inserted.
419fn run_preview(repo: &Repository, args: &PreviewArgs) -> CliResult<()> {

Callers 1

runMethod · 0.85

Calls 9

parse_change_hashFunction · 0.85
print_infoFunction · 0.85
print_cross_view_outcomeFunction · 0.85
print_successFunction · 0.85
current_viewMethod · 0.80
cherry_pickMethod · 0.80
materializeMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected