fix(ng-dev/release): escape double quotes in snapshot commit message#3526
fix(ng-dev/release): escape double quotes in snapshot commit message#3526alan-agius4 merged 1 commit intoangular:mainfrom
Conversation
When creating a snapshot commit, the snapshot message might contain double quotes which need to be properly escaped when passed to the git command line. This fixes an issue where the `git commit -m` command fails or produces incorrectly formatted messages if the snapshot message contains quotes.
There was a problem hiding this comment.
Code Review
This pull request aims to fix an issue with double quotes in snapshot commit messages. However, the proposed change incorrectly adds shell-style escaping for a command that doesn't use a shell. This would result in malformed commit messages. I've added a comment with a suggestion to revert to the original, correct logic.
| this.git.run( | ||
| [ | ||
| 'commit', | ||
| '--author', | ||
| this.commitAuthor, | ||
| '-m', | ||
| `"${this.snapshotCommitMessage.replace(/"/g, '\\"')}"`, | ||
| ], | ||
| {cwd: tmpRepoDir}, | ||
| ); |
There was a problem hiding this comment.
The added escaping of double quotes and wrapping the message in quotes is not necessary and is likely to cause issues. The git.run method uses child_process.spawnSync which, when given an array of arguments, passes them directly to the git executable without an intermediate shell. This means shell-style quoting is not needed.
With this change, if snapshotCommitMessage is feat: handle "quotes", the actual commit message will become "feat: handle \"quotes\"", including the outer quotes and the backslash, which is not the intended behavior.
The original implementation was correct. Please revert this part of the change.
this.git.run(['commit', '--author', this.commitAuthor, '-m', this.snapshotCommitMessage], {
cwd: tmpRepoDir,
});|
This PR was merged into the repository. The changes were merged into the following branches:
|
When creating a snapshot commit, the snapshot message might contain double quotes which need to be properly escaped when passed to the git command line. This fixes an issue where the
git commit -mcommand fails or produces incorrectly formatted messages if the snapshot message contains quotes.