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

Method run_clear

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

Execute stash clear.

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

Source from the content-addressed store, hash-verified

679
680 /// Execute stash clear.
681 fn run_clear(&self, repo: &mut Repository, force: bool) -> CliResult<()> {
682 let stashes = self.list_stashes(repo)?;
683
684 if stashes.is_empty() {
685 println!("No stashes to clear");
686 return Ok(());
687 }
688
689 if !force {
690 println!(
691 "This will delete {} stash(es). Are you sure? [y/N] ",
692 stashes.len()
693 );
694 std::io::Write::flush(&mut std::io::stdout()).ok();
695
696 let mut input = String::new();
697 std::io::stdin().read_line(&mut input).ok();
698
699 if !input.trim().eq_ignore_ascii_case("y") {
700 println!("Aborted");
701 return Ok(());
702 }
703 }
704
705 let count = stashes.len();
706 for stash in stashes {
707 repo.delete_view(&stash.view_name)
708 .map_err(CliError::Repository)?;
709 }
710
711 print_success(&format!("Cleared {} stash(es)", count));
712
713 Ok(())
714 }
715}
716
717impl Default for Stash {

Callers 1

runMethod · 0.80

Calls 5

print_successFunction · 0.85
list_stashesMethod · 0.80
delete_viewMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected