diff --git a/.github/scripts/diff-directories.js b/.github/scripts/diff-directories.js index 15ddefce0..a1bc64bf6 100644 --- a/.github/scripts/diff-directories.js +++ b/.github/scripts/diff-directories.js @@ -46,17 +46,31 @@ function mungeFileContents (fileContent, filePath) { } function displayDiffs (dir1Files, dir2Files, isOpen) { - const out = [] + const out = {} + function add(fileName, string, summary = undefined) { + if (summary === undefined) { + summary = string + } + if (!(shortString in out)) { + out[shortString] = { files: [] } + } + out[shortString].files.push(fileName) + out[shortString].string = string + } for (const [filePath, fileContent] of Object.entries(dir1Files)) { let diffOut = '' + let compareOut = undefined if (filePath in dir2Files) { const fileOut = mungeFileContents(fileContent, filePath) const file2Out = mungeFileContents(dir2Files[filePath], filePath) if (fileOut === file2Out) { - diffOut = `⚠️ File ${filePath} is identical` + diffOut = `⚠️ File is identical` + compareOut = 'identical' } else { // Slice of file header from diff output const fileDiff = diff.createPatch(filePath, fileOut, file2Out).split('\n').slice(2).join('\n') + // Ignore out lines + compareOut = fileDiff.split('\n').slice(3).filter(line => line.startsWith('-') || line.startsWith('+')).join('\n') if (fileDiff) { fileDiffOut = diffOut = ` @@ -71,15 +85,29 @@ ${fileDiff} delete dir2Files[filePath] } else { - diffOut = `❌ File ${filePath} only exists in old changeset` + diffOut = '❌ File only exists in old changeset' + compareOut = 'old 1' } - out.push(renderDetails(filePath, diffOut, isOpen)) + add(filePath, diffOut, compareOut) } for (const filePath of Object.keys(dir2Files)) { - out.push(`❌ File ${filePath} only exists in new changeset`) + add(filePath, '❌ File only exists in new changeset', 'new 2') } - return out + const outString = Object.keys(out).map(key => { + const rollup = out[key] + let outString = '' + // If there's more than one file in the rollup, list them + if (rollup.files.length > 1) { + outString += '\n' + for (const file of rollup.files) { + outString += `- ${file}\n` + } + } + outString += '\n\n' + rollup.string + return renderDetails(rollup.files.join(', '), outString, isOpen) + }).join('\n') + return outString } function renderDetails (section, text, isOpen) { @@ -118,6 +146,6 @@ sortFiles(readFilesRecursively(dir2), 'dir2') for (const [section, files] of Object.entries(sections)) { const isOpen = section === 'latest' - const fileOut = displayDiffs(files.dir1, files.dir2, isOpen).join('\n') + const fileOut = displayDiffs(files.dir1, files.dir2, isOpen) console.log(renderDetails(section, fileOut, isOpen)) } diff --git a/overrides/browsers/chrome-override.json b/overrides/browsers/chrome-override.json index 363208863..544e10e44 100644 --- a/overrides/browsers/chrome-override.json +++ b/overrides/browsers/chrome-override.json @@ -367,7 +367,7 @@ "domain": "dr3fr5q4g2ul9.cloudfront.net" }, { - "disabled_domain": "cnn.io", + "disabled_domain": "cnin.io", "reason": "https://github.com/duckduckgo/privacy-configuration/issues/837" }, {