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

Method run_clear

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

Execute stash clear.

(&self, repo: &mut Repository, force: bool)

Source from the content-addressed store, hash-verified

412
413 /// Execute stash clear.
414 fn run_clear(&self, repo: &mut Repository, force: bool) -> CliResult<()> {
415 if !force {
416 let count = repo
417 .stash_list()
418 .map_err(|message| CliError::Internal(anyhow::anyhow!(message)))?
419 .len();
420 if count == 0 {
421 println!("No stashes to clear");
422 return Ok(());
423 }
424 println!("This will delete {count} stash(es). Are you sure? [y/N] ");
425 std::io::Write::flush(&mut std::io::stdout()).ok();
426 let mut input = String::new();
427 std::io::stdin().read_line(&mut input).ok();
428 if !input.trim().eq_ignore_ascii_case("y") {
429 println!("Aborted");
430 return Ok(());
431 }
432 }
433 let count = repo
434 .stash_clear()
435 .map_err(|message| CliError::InvalidArgument { message })?;
436 if count == 0 {
437 println!("No stashes to clear");
438 } else {
439 print_success(&format!("Cleared {count} stash(es)"));
440 }
441 Ok(())
442 }
443}
444
445impl Default for Stash {

Callers 1

runMethod · 0.80

Calls 6

stdoutFunction · 0.85
print_successFunction · 0.85
stash_listMethod · 0.80
stash_clearMethod · 0.80
lenMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected