Execute stash clear.
(&self, repo: &mut Repository, force: bool)
| 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 | |
| 717 | impl Default for Stash { |
no test coverage detected