Skip to main content

Mountain/IPC/WindServiceHandlers/Git/
HandleFetch.rs

1#![allow(non_snake_case)]
2
3//! `localGit:fetch(operationId, repoPath)`. Plain `git fetch`
4//! against the configured upstream - no remote argument, no
5//! `--all`, mirroring stock VS Code's `LocalGitService.fetch`.
6
7use serde_json::Value;
8
9use crate::IPC::WindServiceHandlers::Git::Shared::RunGit;
10
11pub async fn HandleFetch(Arguments:Vec<Value>) -> Result<Value, String> {
12	let OperationId = Arguments.first().and_then(Value::as_str).unwrap_or("").to_string();
13	let RepoPath = Arguments.get(1).and_then(Value::as_str).unwrap_or("").to_string();
14	if RepoPath.is_empty() {
15		return Err("git:fetch requires repoPath".to_string());
16	}
17	let (ExitCode, _, Stderr) = RunGit(&OperationId, &["fetch".to_string()], Some(&RepoPath)).await?;
18	if ExitCode != 0 {
19		return Err(format!("git fetch failed: {}", Stderr));
20	}
21	Ok(Value::Null)
22}