`atomic stash pop` composes ApplyStash then DropStash (the wire's reserved field 4 documents exactly this client-side composition).
(stash: Option<String>)
| 3799 | /// `atomic stash pop` composes ApplyStash then DropStash (the wire's |
| 3800 | /// reserved field 4 documents exactly this client-side composition). |
| 3801 | pub fn stash_pop(stash: Option<String>) -> CliResult<bool> { |
| 3802 | let Some(session) = Service::open()? else { |
| 3803 | return Ok(false); |
| 3804 | }; |
| 3805 | let stash_id = match stash { |
| 3806 | Some(stash) => stash, |
| 3807 | // Pop's default target is stash@{0}: resolve it through the list. |
| 3808 | None => { |
| 3809 | let stashes = session |
| 3810 | .list_stashes(pb::ListStashesRequest { |
| 3811 | repository: Some(session.reference.clone()), |
| 3812 | })? |
| 3813 | .stashes; |
| 3814 | match stashes.first() { |
| 3815 | Some(first) => first.id.clone(), |
| 3816 | None => { |
| 3817 | return Err(CliError::InvalidArgument { |
| 3818 | message: "No stashes found".to_string(), |
| 3819 | }) |
| 3820 | } |
| 3821 | } |
| 3822 | } |
| 3823 | }; |
| 3824 | stash_apply(Some(stash_id.clone()))?; |
| 3825 | let request = pb::DropStashRequest { |
| 3826 | repository: Some(session.reference.clone()), |
| 3827 | meta: None, |
| 3828 | stash_id: Some(stash_id.clone()), |
| 3829 | all: false, |
| 3830 | }; |
| 3831 | session.drop_stash(request)?; |
| 3832 | print_success(&format!("Dropped {stash_id}")); |
| 3833 | Ok(true) |
| 3834 | } |
| 3835 | |
| 3836 | /// `atomic stash list` over ListStashes. |
| 3837 | pub fn stash_list() -> CliResult<bool> { |
no test coverage detected