Skip to content

Commit

Permalink
Merge pull request #13640 from Expensify/chirag-deploy-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Dec 15, 2022
2 parents 41c0c63 + 3a662ba commit 0e17da8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,17 @@ function getMergeLogsAsJSON(fromRef, toRef) {
})
.then((stdout) => {
// Remove any double-quotes from commit subjects
console.log(`[debug] stdOut: ${stdout}`);
let sanitizedOutput = stdout.replace(/(?<="subject": ").*(?="})/g, subject => subject.replace(/"/g, "'"));
console.log(`[debug] sanitizedOutput 1: ${sanitizedOutput}`);

// Also remove any newlines and escape backslashes
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace('\\', '\\\\');
console.log(`[debug] sanitizedOutput 2: ${sanitizedOutput}`);

// Then format as JSON and convert to a proper JS object
const json = `[${sanitizedOutput}]`.replace('},]', '}]');
console.log(`[debug] json: ${json}`);

return JSON.parse(json);
});
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/javascript/getDeployPullRequestList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,17 @@ function getMergeLogsAsJSON(fromRef, toRef) {
})
.then((stdout) => {
// Remove any double-quotes from commit subjects
console.log(`[debug] stdOut: ${stdout}`);
let sanitizedOutput = stdout.replace(/(?<="subject": ").*(?="})/g, subject => subject.replace(/"/g, "'"));
console.log(`[debug] sanitizedOutput 1: ${sanitizedOutput}`);

// Also remove any newlines and escape backslashes
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace('\\', '\\\\');
console.log(`[debug] sanitizedOutput 2: ${sanitizedOutput}`);

// Then format as JSON and convert to a proper JS object
const json = `[${sanitizedOutput}]`.replace('},]', '}]');
console.log(`[debug] json: ${json}`);

return JSON.parse(json);
});
Expand Down
4 changes: 4 additions & 0 deletions .github/libs/GitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ function getMergeLogsAsJSON(fromRef, toRef) {
})
.then((stdout) => {
// Remove any double-quotes from commit subjects
console.log(`[debug] stdOut: ${stdout}`);
let sanitizedOutput = stdout.replace(/(?<="subject": ").*(?="})/g, subject => subject.replace(/"/g, "'"));
console.log(`[debug] sanitizedOutput 1: ${sanitizedOutput}`);

// Also remove any newlines and escape backslashes
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace('\\', '\\\\');
console.log(`[debug] sanitizedOutput 2: ${sanitizedOutput}`);

// Then format as JSON and convert to a proper JS object
const json = `[${sanitizedOutput}]`.replace('},]', '}]');
console.log(`[debug] json: ${json}`);

return JSON.parse(json);
});
Expand Down

0 comments on commit 0e17da8

Please sign in to comment.