Skip to content

Commit d8a2c64

Browse files
committed
get all commits, verify date arguments
1 parent 99d22cb commit d8a2c64

File tree

1 file changed

+46
-48
lines changed

1 file changed

+46
-48
lines changed

scripts/getCommitsForTesting.js

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,35 +37,32 @@ async function writeTestingCSV() {
3737
let num = title.match(regex)[0].replace(/[\(\)#]/g, '');
3838
let info = await getPR(num);
3939

40-
// Check for "needs testing" label on the PR
41-
if (isReadyForTesting(info.data.labels)) {
42-
// Get testing instructions if it exists
43-
let content = info.data.body;
44-
const match = content.match(/## 📝 Test Instructions:\s*([\s\S]*?)(?=##|$)/);
45-
let testInstructions = '';
46-
if (match) {
47-
testInstructions = match[1];
48-
testInstructions = testInstructions.replace(/<!--[\s\S]*?-->/g, '');
49-
testInstructions = testInstructions.trim();
50-
testInstructions = escapeCSV(testInstructions);
51-
}
52-
53-
if (testInstructions.length > 350) {
54-
row.push('See PR for testing instructions');
55-
} else {
56-
row.push(testInstructions);
57-
}
58-
row.push(info.data.html_url);
59-
60-
if ((/\bs2\b/gi).test(title)) {
61-
s2PRs.push(row);
62-
} else if ((/\brac\b/gi).test(title)) {
63-
racPRs.push(row);
64-
} else if ((/\bv3\b/gi).test(title)) {
65-
v3PRs.push(row);
66-
} else {
67-
otherPRs.push(row);
68-
}
40+
// Get testing instructions if it exists
41+
let content = info.data.body;
42+
const match = content.match(/## 📝 Test Instructions:\s*([\s\S]*?)(?=##|$)/);
43+
let testInstructions = '';
44+
if (match) {
45+
testInstructions = match[1];
46+
testInstructions = testInstructions.replace(/<!--[\s\S]*?-->/g, '');
47+
testInstructions = testInstructions.trim();
48+
testInstructions = escapeCSV(testInstructions);
49+
}
50+
51+
if (testInstructions.length > 350) {
52+
row.push('See PR for testing instructions');
53+
} else {
54+
row.push(testInstructions);
55+
}
56+
row.push(info.data.html_url);
57+
58+
if ((/\bs2\b/gi).test(title)) {
59+
s2PRs.push(row);
60+
} else if ((/\brac\b/gi).test(title)) {
61+
racPRs.push(row);
62+
} else if ((/\bv3\b/gi).test(title)) {
63+
v3PRs.push(row);
64+
} else {
65+
otherPRs.push(row);
6966
}
7067
}
7168
}
@@ -101,16 +98,17 @@ async function listCommits() {
10198
process.exit(1);
10299
}
103100

104-
let start = args.positionals[0];
105-
let end = args.positionals[1];
101+
let start = new Date(args.positionals[0]);
102+
let end = new Date(args.positionals[1]);
103+
104+
if (isNaN(start.getTime()) || isNaN(end.getTime())) {
105+
console.error('Please verify that your date is correctly formatted')
106+
process.exit(1)
107+
}
106108

107109
let startDate = new Date(start).toISOString();
108110
let endDate = new Date(end).toISOString();
109111

110-
if (isNaN(startDate) || isNaN(endDate)) {
111-
console.error('Please verify that your date is correctly formatted');
112-
}
113-
114112
let res = await octokit.request(`GET /repos/adobe/react-spectrum/commits?sha=main&since=${startDate}&until=${endDate}`, {
115113
owner: 'adobe',
116114
repo: 'react-spectrum',
@@ -149,16 +147,16 @@ function escapeCSV(value) {
149147
return `"${escaped}"`;
150148
}
151149

152-
153-
function isReadyForTesting(labels){
154-
if (labels.length === 0) {
155-
return false;
156-
}
157-
for (let label of labels) {
158-
if (label.name === 'needs testing') {
159-
return true;
160-
}
161-
}
162-
163-
return false;
164-
}
150+
// We can bring this back if we start using the "needs testing" label
151+
// function isReadyForTesting(labels){
152+
// if (labels.length === 0) {
153+
// return false;
154+
// }
155+
// for (let label of labels) {
156+
// if (label.name === 'needs testing') {
157+
// return true;
158+
// }
159+
// }
160+
161+
// return false;
162+
// }

0 commit comments

Comments
 (0)