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
index cc81cd3..114b208 100644
--- a/src/tools.rs
+++ b/src/tools.rs
@@ -2268,8 +2268,10 @@ mod tests {
fn run_command_appends_co_author_trailer_to_new_commits() {
let dir = init_test_repo("coauthor_append");
fs::write(dir.join("file.txt"), "two\n").unwrap();
+ // Quote-free command: `cmd /C` does not strip double quotes the way
+ // `sh -c` does, so quoted arguments would break on Windows.
let args = serde_json::json!({
- "command": "git add file.txt && git commit -m \"Update file\"",
+ "command": "git add file.txt && git commit -m Update",
"cwd": dir.display().to_string(),
})
.to_string();
@@ -2293,11 +2295,23 @@ mod tests {
fn run_command_keeps_existing_co_author_trailer() {
let dir = init_test_repo("coauthor_present");
fs::write(dir.join("file.txt"), "two\n").unwrap();
- let command = format!(
- "git add file.txt && git commit -m \"Update file\" -m \"{COMMIT_CO_AUTHOR_TRAILER}\""
+ // The trailer contains spaces and angle brackets, which `cmd /C`
+ // mis-tokenizes (`<` is redirection), so create the trailer-carrying
+ // commit with direct git args and let run_command amend it without
+ // editing: HEAD changes, the message already has the trailer, and the
+ // gate must leave it alone.
+ test_git(&dir, &["add", "file.txt"]);
+ test_git(
+ &dir,
+ &[
+ "commit",
+ "-q",
+ "-m",
+ &format!("Update file\n\n{COMMIT_CO_AUTHOR_TRAILER}"),
+ ],
);
let args = serde_json::json!({
- "command": command,
+ "command": "git commit --amend --no-edit",
"cwd": dir.display().to_string(),
})
.to_string();
@@ -2331,7 +2345,7 @@ mod tests {
fs::write(dir.join("file.txt"), "two\n").unwrap();
let args = serde_json::json!({
- "command": "git add file.txt && git commit -m \"Update file\" && git push -q origin main",
+ "command": "git add file.txt && git commit -m Update && git push -q origin main",
"cwd": dir.display().to_string(),
})
.to_string();