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

Function stash_pop

atomic-cli/src/commands/rpc.rs:3801–3834  ·  view source on GitHub ↗

`atomic stash pop` composes ApplyStash then DropStash (the wire's reserved field 4 documents exactly this client-side composition).

(stash: Option<String>)

Source from the content-addressed store, hash-verified

3799/// `atomic stash pop` composes ApplyStash then DropStash (the wire's
3800/// reserved field 4 documents exactly this client-side composition).
3801pub 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.
3837pub fn stash_list() -> CliResult<bool> {

Callers 1

runMethod · 0.85

Calls 6

openFunction · 0.85
stash_applyFunction · 0.85
print_successFunction · 0.85
list_stashesMethod · 0.45
cloneMethod · 0.45
drop_stashMethod · 0.45

Tested by

no test coverage detected