@henryqw/pi-pr 9.0.5 → 9.0.6

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.
@@ -370,25 +370,30 @@ async function invoke(
370
370
  command: string,
371
371
  args: string[],
372
372
  ): Promise<CommandOutput> {
373
+ const signal = context.signal;
373
374
  let result: unknown;
374
375
  try {
375
376
  result = await pi.exec(command, args, {
376
377
  cwd: context.cwd,
377
- signal: context.signal,
378
+ signal,
378
379
  timeout: EXEC_TIMEOUT_MS,
379
380
  });
380
381
  } catch {
381
382
  fail(action, "command threw");
382
383
  }
383
- return parseCommandOutput(result, action);
384
+ const output = parseCommandOutput(result, action);
385
+ if (output.killed) {
386
+ fail(action, signal?.aborted ? "command was cancelled" : `command timed out after ${EXEC_TIMEOUT_MS} ms`);
387
+ }
388
+ return output;
384
389
  }
385
390
 
386
391
  function commandFailure(action: string, result: CommandOutput, command?: string): never {
387
392
  if (
388
- command === "gh" && !result.killed && result.code !== 0 &&
393
+ command === "gh" && result.code !== 0 &&
389
394
  result.stderr.includes("GraphQL: API rate limit exceeded")
390
395
  ) throw new GitHubRateLimitError();
391
- fail(action, result.killed ? "command was cancelled" : `exit code ${result.code}`);
396
+ fail(action, `exit code ${result.code}`);
392
397
  }
393
398
 
394
399
  async function execute(
@@ -399,7 +404,7 @@ async function execute(
399
404
  args: string[],
400
405
  ): Promise<CommandOutput> {
401
406
  const result = await invoke(pi, context, action, command, args);
402
- if (result.killed || result.code !== 0) commandFailure(action, result, command);
407
+ if (result.code !== 0) commandFailure(action, result, command);
403
408
  return result;
404
409
  }
405
410
 
@@ -989,7 +994,6 @@ async function readConfiguredCreationBaseRef(
989
994
  const result = await invoke(pi, context, "Read creation base configuration", "git", [
990
995
  "config", "--get-all", `branch.${branch}.gh-merge-base`,
991
996
  ]);
992
- if (result.killed) commandFailure("Read creation base configuration", result);
993
997
  if (result.code === 1 && result.stdout === "" && result.stderr === "") return null;
994
998
  if (result.code !== 0) commandFailure("Read creation base configuration", result);
995
999
  if (result.stderr !== "") fail("Read creation base configuration", "unexpected diagnostic");
@@ -1184,7 +1188,7 @@ async function readRemoteAuthority(
1184
1188
  ? ["remote", "get-url", "--push", "--all", remote]
1185
1189
  : ["remote", "get-url", "--all", remote];
1186
1190
  const result = await invoke(pi, context, action, "git", args);
1187
- if (result.killed || result.code !== 0) commandFailure(action, result);
1191
+ if (result.code !== 0) commandFailure(action, result);
1188
1192
  const urls = lines(result.stdout, action, `${kind} URL`);
1189
1193
  if (urls.length !== 1) fail(action, `multiple ${kind} URLs are configured`);
1190
1194
  return parseRemoteUrl(urls[0], kind);
@@ -1241,7 +1245,6 @@ async function readRemoteHeadOid(
1241
1245
  fetchSource,
1242
1246
  `refs/heads/${ref}`,
1243
1247
  ]);
1244
- if (remoteHead.killed) commandFailure("Read remote push ref", remoteHead);
1245
1248
  if (remoteHead.code === 2) {
1246
1249
  if (remoteHead.stdout !== "") fail("Read remote push ref", "invalid absent-ref response");
1247
1250
  return null;
@@ -1256,7 +1259,6 @@ async function readConfigValues(
1256
1259
  key: string,
1257
1260
  ): Promise<string[] | null> {
1258
1261
  const result = await invoke(pi, context, "Read Git configuration", "git", ["config", "--get-all", key]);
1259
- if (result.killed) commandFailure("Read Git configuration", result);
1260
1262
  if (result.code === 1 && result.stdout === "") return [];
1261
1263
  if (result.code !== 0) commandFailure("Read Git configuration", result);
1262
1264
  try {
@@ -1275,7 +1277,6 @@ async function readBooleanConfigValues(
1275
1277
  const result = await invoke(pi, context, "Read Git configuration", "git", [
1276
1278
  "config", "--type=bool", "--get-all", key,
1277
1279
  ]);
1278
- if (result.killed) commandFailure("Read Git configuration", result);
1279
1280
  if (result.code === 1 && result.stdout === "") return [];
1280
1281
  if (result.code !== 0) return null;
1281
1282
  try {
@@ -1344,7 +1345,6 @@ async function readPushTarget(
1344
1345
  context: PullRequestLoadContext,
1345
1346
  ): Promise<TargetReadResult> {
1346
1347
  const worktree = await invoke(pi, context, "Check Git worktree", "git", ["rev-parse", "--is-inside-work-tree"]);
1347
- if (worktree.killed) commandFailure("Check Git worktree", worktree);
1348
1348
  const worktreeOutput = worktree.stdout.replace(/\r\n/g, "\n");
1349
1349
  if (worktree.code === 128 && worktreeOutput === "") {
1350
1350
  const probe = await invoke(pi, context, "Classify Git worktree", "env", [
@@ -1357,7 +1357,6 @@ async function readPushTarget(
1357
1357
  "rev-parse",
1358
1358
  "--is-inside-work-tree",
1359
1359
  ]);
1360
- if (probe.killed) commandFailure("Classify Git worktree", probe);
1361
1360
  if (
1362
1361
  probe.code === 128 && probe.stdout === "" &&
1363
1362
  probe.stderr.replace(/\r\n/g, "\n") ===
@@ -1392,7 +1391,6 @@ async function readPushTarget(
1392
1391
  const remoteNames = normalizedRemotes === "" ? [] : lines(normalizedRemotes, "Read push remotes", "remote");
1393
1392
  if (pushReference === null) {
1394
1393
  const branchCheck = await invoke(pi, context, "Read current branch", "git", ["check-ref-format", "--branch", branch]);
1395
- if (branchCheck.killed) commandFailure("Read current branch", branchCheck);
1396
1394
  if (branchCheck.code !== 0 || branchCheck.stdout.replace(/\r\n/g, "\n") !== `${branch}\n`) {
1397
1395
  return { kind: "blocked", issue: "target" };
1398
1396
  }
@@ -1878,7 +1876,6 @@ export async function readTrackingOid(
1878
1876
  const result = await invoke(pi, context, "Read remote-tracking ref", "git", [
1879
1877
  "rev-parse", "--verify", "--quiet", `${trackingRef}^{commit}`,
1880
1878
  ]);
1881
- if (result.killed) commandFailure("Read remote-tracking ref", result);
1882
1879
  if (result.code === 1 && result.stdout === "") return null;
1883
1880
  if (result.code !== 0) commandFailure("Read remote-tracking ref", result);
1884
1881
  return oid(singleLine(result.stdout, "Read remote-tracking ref", "OID"), "Read remote-tracking ref", "OID");
@@ -1939,7 +1936,6 @@ async function restoreConfigValue(
1939
1936
  const unset = await invoke(pi, context, "Restore branch upstream", "git", [
1940
1937
  "config", "--fixed-value", "--unset-all", key, expected,
1941
1938
  ]);
1942
- if (unset.killed) commandFailure("Restore branch upstream", unset);
1943
1939
  if (unset.code === 5) {
1944
1940
  throw new Error("Restore branch upstream failed: branch configuration changed concurrently");
1945
1941
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@henryqw/pi-pr",
3
- "version": "9.0.5",
3
+ "version": "9.0.6",
4
4
  "description": "Run /pr to safely discover or link the current pull request, then create, update, address feedback, fix CI, or merge when ready.",
5
5
  "keywords": [
6
6
  "pi-package",