MCPcopy Index your code
hub / github.com/AI45Lab/Code / stash

Method stash

core/src/tools/builtin/git.rs:334–379  ·  view source on GitHub ↗

Stash operations.

(
        &self,
        args: &serde_json::Value,
        stash: &dyn WorkspaceGitStashProvider,
    )

Source from the content-addressed store, hash-verified

332
333 /// Stash operations.
334 async fn stash(
335 &self,
336 args: &serde_json::Value,
337 stash: &dyn WorkspaceGitStashProvider,
338 ) -> Result<ToolOutput> {
339 let message = args
340 .get("message")
341 .and_then(|v| v.as_str())
342 .map(ToString::to_string);
343 let include_untracked = args
344 .get("include_untracked")
345 .and_then(|v| v.as_bool())
346 .unwrap_or(false);
347
348 if message.is_some() || include_untracked {
349 match stash
350 .stash(WorkspaceGitStashRequest {
351 message,
352 include_untracked,
353 })
354 .await
355 {
356 Ok(_) => Ok(ToolOutput::success("Created stash".to_string())),
357 Err(e) => Ok(ToolOutput::error(format!("Failed to stash: {e}"))),
358 }
359 } else {
360 match stash.list_stashes().await {
361 Ok(stashes) => {
362 if stashes.is_empty() {
363 return Ok(ToolOutput::success("No stashes found.".to_string()));
364 }
365
366 let entries: Vec<String> = stashes
367 .iter()
368 .map(|stash| format!("{}: {}", stash.index, stash.message))
369 .collect();
370
371 Ok(
372 ToolOutput::success(format!("Stashes:\n{}", entries.join("\n")))
373 .with_metadata(serde_json::json!({ "count": stashes.len() })),
374 )
375 }
376 Err(e) => Ok(ToolOutput::error(format!("Failed to list stashes: {e}"))),
377 }
378 }
379 }
380
381 /// Show remote information.
382 async fn remote(&self, git: &dyn WorkspaceGit) -> Result<ToolOutput> {

Callers 1

executeMethod · 0.45

Calls 5

getMethod · 0.45
as_strMethod · 0.45
list_stashesMethod · 0.45
is_emptyMethod · 0.45
with_metadataMethod · 0.45

Tested by

no test coverage detected