MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / run_git

Function run_git

src/branch/tests.rs:94–125  ·  view source on GitHub ↗
(cwd: &Path, args: &[&str])

Source from the content-addressed store, hash-verified

92}
93
94fn run_git(cwd: &Path, args: &[&str]) {
95 assert!(cwd.is_dir(), "git cwd {cwd:?} should exist");
96 let git = git_program();
97 let mut last_err: Option<std::io::Error> = None;
98 let mut output = None;
99 for attempt in 0..5 {
100 match std::process::Command::new(&git)
101 .args(args)
102 .current_dir(cwd)
103 .output()
104 {
105 Ok(out) => {
106 output = Some(out);
107 break;
108 }
109 Err(e) if e.kind() == std::io::ErrorKind::NotFound && attempt < 4 => {
110 last_err = Some(e);
111 std::thread::sleep(std::time::Duration::from_millis(20 * (attempt + 1)));
112 }
113 Err(e) => panic!("git {args:?} should run (program {git:?}): {e}"),
114 }
115 }
116 let output =
117 output.unwrap_or_else(|| panic!("git {args:?} should run after retries: {last_err:?}"));
118 assert!(
119 output.status.success(),
120 "git {:?} failed\nstdout:\n{}\nstderr:\n{}",
121 args,
122 String::from_utf8_lossy(&output.stdout),
123 String::from_utf8_lossy(&output.stderr)
124 );
125}
126
127#[cfg(windows)]
128fn git_test_root(path: &Path) -> PathBuf {

Callers 3

setup_repo_with_metaFunction · 0.70
add_tracked_branchFunction · 0.70
gc_keeps_default_branchFunction · 0.70

Calls 3

outputMethod · 0.80
kindMethod · 0.80
git_programFunction · 0.70

Tested by

no test coverage detected