`atomic stash drop` over DropStash (all=true covers `stash clear`, which routes without its confirmation prompt — the prompt is the client's job).
(stash: Option<String>, all: bool)
| 3869 | /// which routes without its confirmation prompt — the prompt is the |
| 3870 | /// client's job). |
| 3871 | pub fn stash_drop(stash: Option<String>, all: bool) -> CliResult<bool> { |
| 3872 | let Some(session) = Service::open()? else { |
| 3873 | return Ok(false); |
| 3874 | }; |
| 3875 | // Resolve a bare drop to the newest stash for the display reference. |
| 3876 | let (stash_id, display) = match stash { |
| 3877 | Some(stash) => (stash.clone(), stash), |
| 3878 | None => { |
| 3879 | let stashes = list_stashes_raw(&session)?; |
| 3880 | match stashes.first() { |
| 3881 | Some(first) => (first.id.clone(), "stash@{0}".to_string()), |
| 3882 | None => { |
| 3883 | return Err(CliError::InvalidArgument { |
| 3884 | message: "No stashes found".to_string(), |
| 3885 | }) |
| 3886 | } |
| 3887 | } |
| 3888 | } |
| 3889 | }; |
| 3890 | let request = pb::DropStashRequest { |
| 3891 | repository: Some(session.reference.clone()), |
| 3892 | meta: None, |
| 3893 | stash_id: Some(stash_id), |
| 3894 | all, |
| 3895 | }; |
| 3896 | session.drop_stash(request)?; |
| 3897 | print_success(&format!("Dropped {display}")); |
| 3898 | Ok(true) |
| 3899 | } |
| 3900 | |
| 3901 | fn list_stashes_raw(session: &Service) -> CliResult<Vec<pb::StashInfo>> { |
| 3902 | let request = pb::ListStashesRequest { |
no test coverage detected