Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,13 @@ 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}`);
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace(/\\/g, '\\\\');

// 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
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,13 @@ 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}`);
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace(/\\/g, '\\\\');

// 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
6 changes: 1 addition & 5 deletions .github/libs/GitUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ 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}`);
sanitizedOutput = sanitizedOutput.replace(/(\r\n|\n|\r)/gm, '').replace(/\\/g, '\\\\');

// 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