MCPcopy Create free account
hub / github.com/remix-run/react-router / changeFileCheck

Function changeFileCheck

scripts/pr.ts:140–185  ·  view source on GitHub ↗
(ctx: CheckContext)

Source from the content-addressed store, hash-verified

138}
139
140async function changeFileCheck(ctx: CheckContext): Promise<Action[]> {
141 if (ctx.baseBranch !== "main") return [];
142 if (!["opened", "synchronize", "reopened"].includes(ctx.eventAction)) {
143 return [];
144 }
145
146 let files = await getPrFiles(ctx.prNumber);
147 let regex =
148 /^packages\/[^/]+\/\.changes\/(major|minor|patch|unstable)\.[^/]+\.md$/;
149 let summaries: ChangeFileSummary[] = files
150 .filter((f) => f.status !== "removed" && regex.test(f.filename))
151 .map((f) => {
152 let type = f.filename.match(regex)?.[1] ?? "unknown";
153 let firstLine =
154 fs.readFileSync(f.filename, "utf8").split(/\r?\n/, 1)[0].trim() ??
155 "_No first line found._";
156
157 return {
158 type,
159 firstLine,
160 };
161 });
162
163 console.log(`changeFileCheck: found ${summaries.length} change files`);
164
165 let body = CHANGE_FILE_MISSING_COMMENT;
166
167 if (summaries.length > 0) {
168 body = [
169 CHANGE_FILE_FOUND_COMMENT,
170 "| Type | Change |",
171 "| --- | --- |",
172 ...summaries.map(
173 (s) => `| \`${s.type}\` | ${s.firstLine.replaceAll("|", "\\|")} |`,
174 ),
175 ].join("\n");
176 }
177
178 return [
179 {
180 type: "upsert-sticky-comment",
181 marker: CHANGE_FILE_MARKER,
182 body,
183 },
184 ];
185}
186
187async function featurePrCheck(ctx: CheckContext): Promise<Action[]> {
188 if (ctx.eventAction !== "labeled") return [];

Callers

nothing calls this directly

Calls 2

getPrFilesFunction · 0.90
logMethod · 0.80

Tested by

no test coverage detected