@remogram/cli 0.1.0-beta.1 → 0.1.0-beta.2

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/index.js +26 -2
  2. package/package.json +7 -7
package/index.js CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  assertGitRemote,
19
19
  getEffectiveIngestMaxBytes,
20
20
  FORGE_INGEST_MAX_BYTES_ENV,
21
+ throwIfStaleHeadByNumber,
21
22
  } from '@remogram/core';
22
23
  import { provider as giteaApi } from '@remogram/provider-gitea-api';
23
24
  import { provider as githubApi } from '@remogram/provider-github-api';
@@ -59,6 +60,11 @@ function handleError(err, ctx, asJson) {
59
60
  remoteName: 'origin',
60
61
  repoId: 'unknown/unknown',
61
62
  };
63
+ if (err.staleHeadPacket) {
64
+ output(forgePacket(err.staleHeadPacket.type, baseCtx, err.staleHeadPacket.body, fe), asJson);
65
+ process.exitCode = 1;
66
+ return;
67
+ }
62
68
  output(forgeErrorPacket(baseCtx, fe), asJson);
63
69
  process.exitCode = 1;
64
70
  }
@@ -145,7 +151,7 @@ async function buildDoctorPacket(cwd, providers) {
145
151
  'provider',
146
152
  stubProvider ? 'warn' : 'pass',
147
153
  stubProvider
148
- ? `${config.provider} is not implemented in v1; use an *-api provider`
154
+ ? `${config.provider} is not fully supported in v1; use an *-api provider`
149
155
  : `${config.provider} is registered`,
150
156
  ),
151
157
  );
@@ -337,7 +343,15 @@ export async function runCli(argv, options = {}) {
337
343
  forgeError: forgeError(ERROR_CODES.INVALID_ARGS, '--number required for pr view'),
338
344
  });
339
345
  }
340
- packet = forgePacket(PACKET_TYPES.PR_STATUS, ctx, await provider.prView(ctx, { number }));
346
+ const body = await provider.prView(ctx, { number });
347
+ throwIfStaleHeadByNumber(
348
+ ctx,
349
+ PACKET_TYPES.PR_STATUS,
350
+ body,
351
+ body.head_ref,
352
+ body.head_sha,
353
+ );
354
+ packet = forgePacket(PACKET_TYPES.PR_STATUS, ctx, body);
341
355
  } else if (group === 'pr' && sub === 'checks') {
342
356
  const number = parsePositiveInt(flags.number, '--number');
343
357
  if (number == null && !flags.ref) {
@@ -346,6 +360,16 @@ export async function runCli(argv, options = {}) {
346
360
  });
347
361
  }
348
362
  if (flags.ref) assertGitRef(flags.ref, '--ref');
363
+ if (number != null && !flags.ref) {
364
+ const view = await provider.prView(ctx, { number });
365
+ throwIfStaleHeadByNumber(
366
+ ctx,
367
+ PACKET_TYPES.PR_CHECKS,
368
+ { head_sha: view.head_sha },
369
+ view.head_ref,
370
+ view.head_sha,
371
+ );
372
+ }
349
373
  packet = forgePacket(
350
374
  PACKET_TYPES.PR_CHECKS,
351
375
  ctx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remogram/cli",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.2",
4
4
  "description": "Remogram forge boundary CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,11 +27,11 @@
27
27
  "node": ">=20"
28
28
  },
29
29
  "dependencies": {
30
- "@remogram/core": "0.1.0-beta.1",
31
- "@remogram/provider-gitea-api": "0.1.0-beta.1",
32
- "@remogram/provider-github-api": "0.1.0-beta.1",
33
- "@remogram/provider-gitlab-api": "0.1.0-beta.1",
34
- "@remogram/provider-gitea-tea": "0.1.0-beta.1",
35
- "@remogram/provider-github-gh": "0.1.0-beta.1"
30
+ "@remogram/core": "0.1.0-beta.2",
31
+ "@remogram/provider-gitea-api": "0.1.0-beta.2",
32
+ "@remogram/provider-github-api": "0.1.0-beta.2",
33
+ "@remogram/provider-gitlab-api": "0.1.0-beta.2",
34
+ "@remogram/provider-gitea-tea": "0.1.0-beta.2",
35
+ "@remogram/provider-github-gh": "0.1.0-beta.2"
36
36
  }
37
37
  }