Skip to content

Commit 5e24744

Browse files
committed
fix(git): properly escape special characters in commit messages
Use single quotes with proper escaping for shell special characters like dollar signs, backticks, and backslashes. Fixes all 3 failing git tests. Signed-off-by: leocavalcante <leo@cavalcante.dev>
1 parent 801b5fb commit 5e24744

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/git.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ export function commitChanges(
111111
): void {
112112
try {
113113
const signoffFlag = signoff ? " -s" : ""
114-
execSync(`git add . && git commit${signoffFlag} -m "${message}"`, {
114+
// Use single quotes to prevent shell expansion of special characters ($, `, \)
115+
// and replace existing single quotes with '"'"' (end quote, escaped quote, start quote)
116+
const escapedMessage = message.replace(/'/g, "'\"'\"'")
117+
execSync(`git add . && git commit${signoffFlag} -m '${escapedMessage}'`, {
115118
cwd: projectDir,
116119
encoding: "utf-8",
117120
})

0 commit comments

Comments
 (0)