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

Function stash_pop

atomic-cli/src/commands/rpc.rs:3802–3835  ·  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

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

Callers 1

runMethod · 0.85

Calls 6

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

Tested by

no test coverage detected