MCPcopy Index your code
hub / github.com/adobe/react-spectrum / generateData

Function generateData

scripts/getCommitsForTesting.mjs:46–158  ·  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 otherPRs = [];
67
68 // Off PRs are currently open PRs with the 'test off PR' label
69 let offPRs = openOffPRs.map(pr => {
70 let labels = new Set(pr.labels.map(l => l.name));
71 let matches = [...validLabels].filter(name => labels.has(name));
72
73 let component = '';
74 if (matches.length > 0) {
75 if (matches.includes('documentation')) {
76 component = 'Docs';
77 } else {
78 component = matches.sort().join('/');
79 }
80 }
81
82 if (matches.length === 0) {
83 component = removePRNumber(pr.title);
84 }
85
86 let testInstructions = extractTestInstructions(pr.body);
87 return [
88 component,
89 testInstructions.length > 300 ? 'See PR for testing instructions' : testInstructions,
90 pr.html_url,
91 removePRNumber(pr.title)
92 ];
93 });
94
95 for (let i = 0; i < commitsWithPRs.length; i++) {
96 let {title, num} = commitsWithPRs[i];
97 let result = settled[i];
98 if (result.status === 'rejected') {
99 console.warn(`Failed to fetch PR #${num}: ${result.reason}`);
100 continue;
101 }
102 let info = result.value;
103 let labels = new Set(info.data.labels.map(label => label.name));

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