MCPcopy Create free account
hub / github.com/adobe/react-spectrum / generateData

Function generateData

scripts/getCommitsForTesting.mjs:46–164  ·  view source on GitHub ↗
(startDate, endDate)

Source from the content-addressed store, hash-verified

44}
45
46export async function generateData(startDate, endDate) {
47 let [data, openOffPRs] = await Promise.all([listCommits(startDate, endDate), listOpenOffPRs()]);
48
49 // First pass: extract PR numbers from commit messages
50 let commitsWithPRs = [];
51 for (let d of data) {
52 let title = d.commit.message.split('\n')[0];
53 let match = title.match(/\(#(\d+)\)/);
54 if (match) {
55 commitsWithPRs.push({title, num: match[1]});
56 }
57 }
58
59 // Fetch all PRs in parallel, tolerating individual failures
60 let settled = await Promise.allSettled(commitsWithPRs.map(({num}) => getPR(num)));
61
62 // Second pass: categorize by label
63 let s2PRs = [];
64 let racPRs = [];
65 let v3PRs = [];
66 let aiPRs = [];
67 let otherPRs = [];
68
69 // Off PRs are currently open PRs with the 'test off PR' label
70 let offPRs = openOffPRs.map(pr => {
71 let labels = new Set(pr.labels.map(l => l.name));
72 let matches = [...validLabels].filter(name => labels.has(name));
73
74 let component = '';
75 if (matches.length > 0) {
76 if (matches.includes('documentation')) {
77 component = 'Docs';
78 } else {
79 component = matches.sort().join('/');
80 }
81 }
82
83 if (matches.length === 0) {
84 component = removePRNumber(pr.title);
85 }
86
87 let testInstructions = extractTestInstructions(pr.body);
88 return [
89 component,
90 testInstructions.length > 300 ? 'See PR for testing instructions' : testInstructions,
91 pr.html_url,
92 removePRNumber(pr.title)
93 ];
94 });
95
96 for (let i = 0; i < commitsWithPRs.length; i++) {
97 let {title, num} = commitsWithPRs[i];
98 let result = settled[i];
99 if (result.status === 'rejected') {
100 console.warn(`Failed to fetch PR #${num}: ${result.reason}`);
101 continue;
102 }
103 let info = result.value;

Callers 2

mainFunction · 0.90
generateCSVFunction · 0.85

Calls 9

listCommitsFunction · 0.85
listOpenOffPRsFunction · 0.85
getPRFunction · 0.85
removePRNumberFunction · 0.85
extractTestInstructionsFunction · 0.85
pushMethod · 0.80
filterMethod · 0.65
hasMethod · 0.65
sortMethod · 0.65

Tested by

no test coverage detected