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

Method run

atomic-cli/src/commands/stash.rs:453–505  ·  view source on GitHub ↗

Execute the stash command.

(&self)

Source from the content-addressed store, hash-verified

451impl Command for Stash {
452 /// Execute the stash command.
453 fn run(&self) -> CliResult<()> {
454 // Route through the daemon when reachable (the domain module is
455 // shared, so behavior is identical); show stays local and clear
456 // keeps its confirmation prompt locally.
457 let routed = match &self.command {
458 None => crate::commands::rpc::stash_push(
459 self.message.clone(),
460 self.include_untracked,
461 self.keep,
462 )?,
463 Some(StashSubcommand::Push {
464 message,
465 include_untracked,
466 keep,
467 }) => crate::commands::rpc::stash_push(message.clone(), *include_untracked, *keep)?,
468 Some(StashSubcommand::Pop { stash }) => crate::commands::rpc::stash_pop(stash.clone())?,
469 Some(StashSubcommand::Apply { stash }) => {
470 crate::commands::rpc::stash_apply(stash.clone())?
471 }
472 Some(StashSubcommand::List) => crate::commands::rpc::stash_list()?,
473 Some(StashSubcommand::Drop { stash }) => {
474 crate::commands::rpc::stash_drop(stash.clone(), false)?
475 }
476 _ => false,
477 };
478 if routed {
479 return Ok(());
480 }
481
482 // Find repository
483 let repo_root = find_repository_root()?;
484 let mut repo = Repository::open(&repo_root).map_err(CliError::Repository)?;
485
486 match &self.command {
487 None => {
488 // Default action: push
489 self.run_push(&mut repo, None, self.include_untracked, self.keep)
490 }
491 Some(StashSubcommand::Push {
492 message,
493 include_untracked,
494 keep,
495 }) => self.run_push(&mut repo, message.clone(), *include_untracked, *keep),
496 Some(StashSubcommand::Pop { stash }) => self.run_pop(&mut repo, stash.as_deref()),
497 Some(StashSubcommand::Apply { stash }) => self.run_apply(&mut repo, stash.as_deref()),
498 Some(StashSubcommand::List) => self.run_list(&repo),
499 Some(StashSubcommand::Show { stash, patch }) => {
500 self.run_show(&repo, stash.as_deref(), *patch)
501 }
502 Some(StashSubcommand::Drop { stash }) => self.run_drop(&mut repo, stash.as_deref()),
503 Some(StashSubcommand::Clear { force }) => self.run_clear(&mut repo, *force),
504 }
505 }
506}
507
508// Tests

Callers

nothing calls this directly

Calls 15

stash_pushFunction · 0.85
stash_popFunction · 0.85
stash_applyFunction · 0.85
stash_listFunction · 0.85
stash_dropFunction · 0.85
find_repository_rootFunction · 0.85
openFunction · 0.85
run_pushMethod · 0.80
run_popMethod · 0.80
run_applyMethod · 0.80
run_listMethod · 0.80
run_showMethod · 0.80

Tested by

no test coverage detected