Skip to content

Commit 0b69990

Browse files
authored
fix(git): escape single quotes in commit messages (#2337)
1 parent 609fb65 commit 0b69990

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

crates/forge_app/src/git_app.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,10 @@ where
154154

155155
// Set ForgeCode as the committer while keeping the user as the author
156156
// by prefixing the command with environment variables
157+
// Escape single quotes in the message by replacing ' with '\''
158+
let escaped_message = message.replace('\'', r"'\''");
157159
let commit_command = format!(
158-
"GIT_COMMITTER_NAME='ForgeCode' GIT_COMMITTER_EMAIL='noreply@forgecode.dev' git commit {flags} -m '{message}'"
160+
"GIT_COMMITTER_NAME='ForgeCode' GIT_COMMITTER_EMAIL='noreply@forgecode.dev' git commit {flags} -m '{escaped_message}'"
159161
);
160162

161163
let commit_result = self

0 commit comments

Comments
 (0)