Run a Git command with stdin and return trimmed stdout (used for plumbing like `commit-tree`, whose stdin carries the commit message).
(root: &Path, args: &[&str], stdin: &[u8])
| 111 | /// Run a Git command with stdin and return trimmed stdout (used for |
| 112 | /// plumbing like `commit-tree`, whose stdin carries the commit message). |
| 113 | fn git_stdin_output(root: &Path, args: &[&str], stdin: &[u8]) -> String { |
| 114 | let mut child = Command::new("git") |
| 115 | .args(args) |
| 116 | .current_dir(root) |
| 117 | .env("GIT_AUTHOR_NAME", "CB-9B Tests") |
| 118 | .env("GIT_AUTHOR_EMAIL", "cb9b@example.com") |
| 119 | .env("GIT_COMMITTER_NAME", "CB-9B Tests") |
| 120 | .env("GIT_COMMITTER_EMAIL", "cb9b@example.com") |
| 121 | .stdin(Stdio::piped()) |
| 122 | .stdout(Stdio::piped()) |
| 123 | .stderr(Stdio::piped()) |
| 124 | .spawn() |
| 125 | .expect("run git with stdin"); |
| 126 | child |
| 127 | .stdin |
| 128 | .as_mut() |
| 129 | .unwrap() |
| 130 | .write_all(stdin) |
| 131 | .expect("write git stdin"); |
| 132 | let output = child.wait_with_output().expect("wait for git"); |
| 133 | assert!( |
| 134 | output.status.success(), |
| 135 | "git {args:?} failed: {}", |
| 136 | String::from_utf8_lossy(&output.stderr) |
| 137 | ); |
| 138 | String::from_utf8(output.stdout) |
| 139 | .expect("utf8 git output") |
| 140 | .trim() |
| 141 | .to_string() |
| 142 | } |
| 143 | |
| 144 | fn atomic_stdin(root: &Path, home: &Path, args: &[&str], stdin: &[u8]) -> Output { |
| 145 | let mut child = Command::new(ATOMIC_BIN) |
no test coverage detected