Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACS-5400] Fix incomplete string escaping #8721

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cli/scripts/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function getCommits(options: DiffOptions): Array<Commit> {
let log = shell.exec(command, { cwd: options.dir, silent: true }).toString();

// https://stackoverflow.com/a/13928240/14644447
log = log.trim().replace(/"/gm, '\\"').replace(/\^@\^/gm, '"');
log = JSON.stringify(log.trim()).slice(1, -1).replace(/\^@\^/gm, '"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure it is going to work as log is not an object so you can't stringify it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log is a string, we use JSON.stringity to escape the quotes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you test the changelog command? does it produce the expected output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a fix, now works as expected

if (log.endsWith(',')) {
log = log.substring(0, log.length - 1);
}

return log.split('\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter));
return log.split('\\n').map(str => JSON.parse(str) as Commit).filter(commit => commitAuthorAllowed(commit, authorFilter));
}

function commitAuthorAllowed(commit: Commit, authorFilter: string): boolean {
Expand Down