fix: use git commit -F - to preserve newlines in commit messages

commitFileWithBody passed the message through JSON.stringify with
git commit -m, which escaped newlines to literal \n characters.
Switch to git commit -F - with stdin input to preserve actual newlines.
This commit is contained in:
Tiara Rodney 2026-03-20 19:08:44 +01:00
parent c6704c3a04
commit 2f1d2c30af
No known key found for this signature in database
GPG key ID: 5CD8EC1D46106723

View file

@ -18,7 +18,7 @@ export function commitFile(path: string, message: string, cwd = process.cwd()):
export function commitFileWithBody(path: string, header: string, body: string, cwd = process.cwd()): void {
execSync(`git add ${path}`, { cwd })
const msg = `${header}\n\n${body}`
execSync(`git commit -m ${JSON.stringify(msg)}`, { cwd })
execSync(`git commit -F -`, { cwd, input: msg })
}
export function branchExists(branch: string, cwd = process.cwd()): boolean {