Skip to content

Commit c701a7b

Browse files
authored
chore: rename column in post-validation script (#153)
1 parent 4f199f7 commit c701a7b

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

.github/scripts/post-merge-validation-tracker.mjs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function headerRowFor(type) {
6666
'Merged Time (UTC)',
6767
'Author',
6868
'PR Size',
69-
'Auto Tests',
69+
'Tests changes?',
7070
'Team Responsible',
7171
colG,
7272
colH,
@@ -88,10 +88,23 @@ async function ensureSheetExists(authClient, title, platformType) {
8888
});
8989

9090
const sheetsList = meta.data.sheets || [];
91-
const existing = sheetsList.find((s) => s.properties?.title === title);
92-
if (existing) return { sheetId: existing.properties.sheetId, isNew: false };
9391

94-
return createSheetFromTemplateOrBlank(authClient, sheetsList, title, platformType);
92+
// First, try to find the exact title (with "pre-" prefix)
93+
let existing = sheetsList.find((s) => s.properties?.title === title);
94+
if (existing) return { sheetId: existing.properties.sheetId, actualTitle: title, isNew: false };
95+
96+
// If not found and title starts with "pre-", try without the "pre-" prefix
97+
if (title.startsWith('pre-')) {
98+
const titleWithoutPrefix = title.replace(/^pre-/, '');
99+
existing = sheetsList.find((s) => s.properties?.title === titleWithoutPrefix);
100+
if (existing) {
101+
console.log(`Found renamed tab: "${titleWithoutPrefix}" (originally looking for "${title}")`);
102+
return { sheetId: existing.properties.sheetId, actualTitle: titleWithoutPrefix, isNew: false };
103+
}
104+
}
105+
106+
const result = await createSheetFromTemplateOrBlank(authClient, sheetsList, title, platformType);
107+
return { ...result, actualTitle: title };
95108
}
96109

97110
async function createSheetFromTemplateOrBlank(authClient, sheetsList, title, platformType) {
@@ -127,7 +140,7 @@ async function createSheetFromTemplateOrBlank(authClient, sheetsList, title, pla
127140
await sheets.spreadsheets.values.update({
128141
spreadsheetId,
129142
auth: authClient,
130-
range: `${title}!A2:I2`,
143+
range: `${title}!A2:H2`,
131144
valueInputOption: 'USER_ENTERED',
132145
requestBody: { values: [headerRowFor(platformType)] },
133146
});
@@ -183,7 +196,7 @@ async function createSheetFromTemplateOrBlank(authClient, sheetsList, title, pla
183196
await sheets.spreadsheets.values.update({
184197
spreadsheetId,
185198
auth: authClient,
186-
range: `${title}!A2:I2`,
199+
range: `${title}!A2:H2`,
187200
valueInputOption: 'USER_ENTERED',
188201
requestBody: { values: [headerRowFor(platformType)] },
189202
});
@@ -210,7 +223,7 @@ async function readRows(authClient, title) {
210223
const res = await sheets.spreadsheets.values.get({
211224
spreadsheetId,
212225
auth: authClient,
213-
range: `${title}!A3:I`,
226+
range: `${title}!A3:H`,
214227
});
215228
return res.data.values || [];
216229
} catch (e) {
@@ -224,7 +237,7 @@ async function appendRows(authClient, title, rows) {
224237
await sheets.spreadsheets.values.append({
225238
spreadsheetId,
226239
auth: authClient,
227-
range: `${title}!A4:I`,
240+
range: `${title}!A4:H`,
228241
valueInputOption: 'USER_ENTERED',
229242
insertDataOption: 'INSERT_ROWS',
230243
requestBody: { values: rows },
@@ -535,7 +548,6 @@ async function buildTabGrouping(owner, repo, relevantItems, sinceDateISO) {
535548
extractTeam(pr.labels || []),
536549
'',
537550
'',
538-
'',
539551
];
540552
tabToRows.get(title).entries.push({ row, mergedAtIso: pr.closed_at || '' });
541553
}
@@ -660,9 +672,9 @@ async function checkAutomatedTestFiles(owner, repo, prNumber) {
660672
}
661673

662674
async function processTab(authClient, title, entries, platformType) {
663-
const { sheetId, isNew } = await ensureSheetExists(authClient, title, platformType);
664-
const existing = await readRows(authClient, title);
665-
console.log(`Tab=${title} existingRows=${existing.length}, incomingRows=${entries.length}`);
675+
const { sheetId, actualTitle, isNew } = await ensureSheetExists(authClient, title, platformType);
676+
const existing = await readRows(authClient, actualTitle);
677+
console.log(`Tab=${actualTitle} existingRows=${existing.length}, incomingRows=${entries.length}`);
666678
const existingKeys = new Set(
667679
existing
668680
.map((r) => parsePrNumberFromCell(r[0]))
@@ -682,10 +694,10 @@ async function processTab(authClient, title, entries, platformType) {
682694
if (key) existingKeys.add(key);
683695
}
684696
}
685-
console.log(`Tab=${title} toInsertAfterDedup=${deduped.length}`);
697+
console.log(`Tab=${actualTitle} toInsertAfterDedup=${deduped.length}`);
686698
let inserted = 0;
687699
if (deduped.length) {
688-
await appendRows(authClient, title, deduped);
700+
await appendRows(authClient, actualTitle, deduped);
689701
inserted += deduped.length;
690702
}
691703
if (isNew) {

0 commit comments

Comments
 (0)