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

Function git_output

crates/opencode-session/src/snapshot.rs:229–249  ·  view source on GitHub ↗
(directory: &Path, git_dir: &Path, args: &[&str])

Source from the content-addressed store, hash-verified

227}
228
229fn git_output(directory: &Path, git_dir: &Path, args: &[&str]) -> Result<Output> {
230 let output = Command::new("git")
231 .arg("--git-dir")
232 .arg(git_dir)
233 .arg("--work-tree")
234 .arg(directory)
235 .args(args)
236 .current_dir(directory)
237 .output()
238 .with_context(|| format!("failed to run git command: git {}", args.join(" ")))?;
239
240 if !output.status.success() {
241 anyhow::bail!(
242 "git command failed: git {}: {}",
243 args.join(" "),
244 String::from_utf8_lossy(&output.stderr).trim()
245 );
246 }
247
248 Ok(output)
249}
250
251fn git_add_all(directory: &Path, git_dir: &Path) -> Result<()> {
252 // Exclude the snapshot repo itself when it lives under worktree.

Callers 7

trackMethod · 0.70
revertMethod · 0.70
restoreMethod · 0.70
diffMethod · 0.70
diff_fullMethod · 0.70
ensure_snapshot_repoFunction · 0.70
git_add_allFunction · 0.70

Calls 3

newFunction · 0.85
outputMethod · 0.80
successMethod · 0.45

Tested by

no test coverage detected