Skip to content

Commit 5c83ed8

Browse files
Add filename clarity and docs link (duckduckgo#3415)
* Add filename clarity and docs link * Add sample config change * Remove test * Lint fix
1 parent 034b8e9 commit 5c83ed8

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

.github/scripts/diff-directories.js

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,46 @@ ${fileDiff}
114114
.map((key) => {
115115
const rollup = rollupGrouping[key];
116116
let outString = '';
117-
let title = rollup.files[0];
117+
let title;
118+
119+
// Create descriptive title based on file count and type
120+
if (rollup.files.length === 1) {
121+
title = rollup.files[0];
122+
} else {
123+
const fileCount = rollup.files.length;
124+
if (key === 'identical') {
125+
title = `${fileCount} files identical`;
126+
} else if (key === 'old 1') {
127+
title = `${fileCount} files only in old changeset`;
128+
} else if (key === 'new 2') {
129+
title = `${fileCount} files only in new changeset`;
130+
} else {
131+
title = `${fileCount} files changed`;
132+
}
133+
}
134+
118135
// If there's more than one file in the rollup, list them
119136
if (rollup.files.length > 1) {
120-
title += ` (${rollup.files.length - 1} more)`;
121137
outString += '\n';
122138
for (const file of rollup.files) {
123139
outString += `- ${file}\n`;
124140
}
141+
142+
// Simple replacement of the last filename with additional info
143+
if (rollup.string.includes('```diff')) {
144+
const lastFileName = rollup.files[rollup.files.length - 1];
145+
const modifiedDiff = rollup.string.replace(
146+
`--- ${lastFileName}`,
147+
`--- ${lastFileName} (and ${rollup.files.length - 1} other files)`,
148+
);
149+
outString += '\n\n' + modifiedDiff;
150+
} else {
151+
outString += '\n\n' + rollup.string;
152+
}
153+
} else {
154+
outString += '\n\n' + rollup.string;
125155
}
126-
outString += '\n\n' + rollup.string;
156+
127157
return renderDetails(title, outString, isOpen);
128158
})
129159
.join('\n');
@@ -178,6 +208,6 @@ for (const [
178208
files,
179209
] of Object.entries(sections)) {
180210
const isOpen = section === 'latest';
181-
const fileOut = displayDiffs(files.dir1, files.dir2, isOpen);
211+
const fileOut = displayDiffs(files.dir1 || {}, files.dir2 || {}, isOpen);
182212
console.log(renderDetails(section, fileOut, isOpen));
183213
}

.github/workflows/auto-respond-pr.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Auto Respond to PR Workflow
2+
#
3+
# This workflow automatically generates and posts diff comments showing changes to generated configuration files.
4+
#
5+
# ## Generated Diff Output Guide:
6+
# - **X files changed**: Multiple files with identical changes (collapsed for readability)
7+
# - **X files identical**: Files that are exactly the same between base and PR branches
8+
# - **File headers**: Show `--- filename (and X other files)` when multiple files share the same diff
9+
# - **File lists**: Individual files are listed under each collapsed section
10+
# - **Sections**: `latest` (current config version, expanded) and `legacy` (older versions, collapsed)
11+
#
12+
# The diff script groups files by their actual changes to reduce noise and improve review efficiency.
13+
114
name: Auto Respond to PR
215

316
on:
@@ -95,7 +108,7 @@ jobs:
95108
const prNumber = context.issue.number;
96109
const diffOutput = fs.readFileSync('diff_output.txt', 'utf8');
97110
let commentBody = `
98-
### Generated file outputs:
111+
### [Generated file outputs](https://github.com/duckduckgo/privacy-configuration/blob/main/.github/workflows/auto-respond-pr.yml#L5-L12):
99112
*Time updated:* ${new Date().toUTCString()}
100113
${diffOutput}
101114
`

0 commit comments

Comments
 (0)