@setoelkahfi / sigit / commits / 395f555

Fix Windows CI: keep co-author test commands quote-free

The two new tests drove git through run_command with quoted messages and, in one case, the trailer itself on the command line. sh -c strips the quotes; cmd /C does not, and it treats the angle brackets in the trailer's email as redirection, so both tests failed on the Windows runner. The commit commands now use single-word messages, and the trailer-carrying commit is created with direct git args, with run_command exercising the gate through an amend that changes HEAD without touching the message.

paydii committed Jul 4, 2026 at 22:58 UTC 395f555f68a1fc623278d1a0f3e9b1bdde88d258
1 file changed +19 -5
src/tools.rs
+19 -5
@@ -2268,8 +2268,10 @@ mod tests {
2268 fn run_command_appends_co_author_trailer_to_new_commits() {
2269 let dir = init_test_repo("coauthor_append");
2270 fs::write(dir.join("file.txt"), "two\n").unwrap();
2271 + // Quote-free command: `cmd /C` does not strip double quotes the way
2272 + // `sh -c` does, so quoted arguments would break on Windows.
2273 let args = serde_json::json!({
2272 - "command": "git add file.txt && git commit -m \"Update file\"",
2274 + "command": "git add file.txt && git commit -m Update",
2275 "cwd": dir.display().to_string(),
2276 })
2277 .to_string();
@@ -2293,11 +2295,23 @@ mod tests {
2295 fn run_command_keeps_existing_co_author_trailer() {
2296 let dir = init_test_repo("coauthor_present");
2297 fs::write(dir.join("file.txt"), "two\n").unwrap();
2296 - let command = format!(
2297 - "git add file.txt && git commit -m \"Update file\" -m \"{COMMIT_CO_AUTHOR_TRAILER}\""
2298 + // The trailer contains spaces and angle brackets, which `cmd /C`
2299 + // mis-tokenizes (`<` is redirection), so create the trailer-carrying
2300 + // commit with direct git args and let run_command amend it without
2301 + // editing: HEAD changes, the message already has the trailer, and the
2302 + // gate must leave it alone.
2303 + test_git(&dir, &["add", "file.txt"]);
2304 + test_git(
2305 + &dir,
2306 + &[
2307 + "commit",
2308 + "-q",
2309 + "-m",
2310 + &format!("Update file\n\n{COMMIT_CO_AUTHOR_TRAILER}"),
2311 + ],
2312 );
2313 let args = serde_json::json!({
2300 - "command": command,
2314 + "command": "git commit --amend --no-edit",
2315 "cwd": dir.display().to_string(),
2316 })
2317 .to_string();
@@ -2331,7 +2345,7 @@ mod tests {
2345
2346 fs::write(dir.join("file.txt"), "two\n").unwrap();
2347 let args = serde_json::json!({
2334 - "command": "git add file.txt && git commit -m \"Update file\" && git push -q origin main",
2348 + "command": "git add file.txt && git commit -m Update && git push -q origin main",
2349 "cwd": dir.display().to_string(),
2350 })
2351 .to_string();