@ravshansbox/pi-next-issue 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/github.ts +17 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ravshansbox/pi-next-issue",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "Pi extension that works through GitHub issues in the background",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/github.ts CHANGED
@@ -227,15 +227,24 @@ export async function failedLogs(repo: Repo, pr: number, maxChars: number): Prom
227
227
  const failed = (await readChecks(repo, pr)).filter(
228
228
  (check) => check.bucket === 'fail' || check.bucket === 'cancel',
229
229
  );
230
- const share = Math.max(1, Math.floor(maxChars / Math.max(1, failed.length)));
231
- const parts: string[] = [];
230
+ const groups = new Map<string, { names: string[]; runId: string | undefined }>();
232
231
  for (const check of failed) {
233
- parts.push(`## ${check.name}`);
234
232
  const runId = /\/actions\/runs\/(\d+)/.exec(check.link)?.[1];
235
- if (runId !== undefined) {
236
- const logs = await run('gh', ['run', 'view', runId, '--log-failed', '--repo', repo.slug], {
237
- cwd: repo.root,
238
- });
233
+ const key = runId ?? `check:${check.name}`;
234
+ const group = groups.get(key) ?? { names: [], runId };
235
+ group.names.push(check.name);
236
+ groups.set(key, group);
237
+ }
238
+ const share = Math.max(1, Math.floor(maxChars / Math.max(1, groups.size)));
239
+ const parts: string[] = [];
240
+ for (const group of groups.values()) {
241
+ parts.push(`## ${group.names.join(', ')}`);
242
+ if (group.runId !== undefined) {
243
+ const logs = await run(
244
+ 'gh',
245
+ ['run', 'view', group.runId, '--log-failed', '--repo', repo.slug],
246
+ { cwd: repo.root },
247
+ );
239
248
  parts.push((logs.stdout || logs.stderr).slice(-share));
240
249
  }
241
250
  }
@@ -273,6 +282,6 @@ export async function merge(
273
282
  if (Date.now() >= deadline) {
274
283
  return { merged: false, reason: 'the merge did not finish in time' };
275
284
  }
276
- await sleep(Math.min(POLL_MS, deadline - Date.now()), undefined, { signal });
285
+ await sleep(Math.max(0, Math.min(POLL_MS, deadline - Date.now())), undefined, { signal });
277
286
  }
278
287
  }