MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / run_git

Function run_git

crates/opencode-server/src/worktree.rs:25–38  ·  view source on GitHub ↗
(args: &[&str], cwd: &Path)

Source from the content-addressed store, hash-verified

23}
24
25fn run_git(args: &[&str], cwd: &Path) -> Result<String, WorktreeError> {
26 let output = Command::new("git")
27 .args(args)
28 .current_dir(cwd)
29 .output()
30 .map_err(|e| WorktreeError::GitError(e.to_string()))?;
31
32 if !output.status.success() {
33 let stderr = String::from_utf8_lossy(&output.stderr);
34 return Err(WorktreeError::GitError(stderr.to_string()));
35 }
36
37 Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
38}
39
40fn is_git_repo(path: &Path) -> bool {
41 path.join(".git").exists() || run_git(&["rev-parse", "--git-dir"], path).is_ok()

Callers 5

is_git_repoFunction · 0.85
list_worktreesFunction · 0.85
create_worktreeFunction · 0.85
remove_worktreeFunction · 0.85
prune_worktreesFunction · 0.85

Calls 3

newFunction · 0.85
outputMethod · 0.80
successMethod · 0.45

Tested by

no test coverage detected