@git.zone/cli 7.2.5 → 7.2.7

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 (30) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/helpers.workflow.d.ts +30 -1
  3. package/dist_ts/helpers.workflow.js +55 -3
  4. package/dist_ts/mod_config/index.js +23 -2
  5. package/dist_ts/mod_release/classes.releasejournal.d.ts +34 -0
  6. package/dist_ts/mod_release/classes.releasejournal.js +134 -2
  7. package/dist_ts/mod_release/helpers.giteaassets.d.ts +75 -3
  8. package/dist_ts/mod_release/helpers.giteaassets.js +303 -53
  9. package/dist_ts/mod_release/helpers.gitremote.d.ts +52 -0
  10. package/dist_ts/mod_release/helpers.gitremote.js +87 -0
  11. package/dist_ts/mod_release/helpers.releasebranch.d.ts +5 -0
  12. package/dist_ts/mod_release/helpers.releasebranch.js +39 -15
  13. package/dist_ts/mod_release/helpers.releasepreparation.js +18 -8
  14. package/dist_ts/mod_release/helpers.releasepublication.d.ts +6 -1
  15. package/dist_ts/mod_release/helpers.releasepublication.js +31 -21
  16. package/dist_ts/mod_release/index.js +216 -64
  17. package/dist_ts/mod_release/interfaces.giteaassets.d.ts +18 -3
  18. package/package.json +3 -3
  19. package/readme.md +106 -24
  20. package/ts/00_commitinfo_data.ts +1 -1
  21. package/ts/helpers.workflow.ts +123 -1
  22. package/ts/mod_config/index.ts +25 -0
  23. package/ts/mod_release/classes.releasejournal.ts +181 -1
  24. package/ts/mod_release/helpers.giteaassets.ts +438 -75
  25. package/ts/mod_release/helpers.gitremote.ts +147 -0
  26. package/ts/mod_release/helpers.releasebranch.ts +75 -30
  27. package/ts/mod_release/helpers.releasepreparation.ts +25 -7
  28. package/ts/mod_release/helpers.releasepublication.ts +45 -42
  29. package/ts/mod_release/index.ts +333 -85
  30. package/ts/mod_release/interfaces.giteaassets.ts +20 -2
@@ -0,0 +1,147 @@
1
+ import * as plugins from "./mod.plugins.js";
2
+ import { describeCommandFailure } from "./helpers.commandfailure.js";
3
+
4
+ /** Bound of one `git ls-remote` attempt unless `release.targets.git.remoteTimeoutSeconds` sets it. */
5
+ export const defaultReleaseGitRemoteTimeoutSeconds = 180;
6
+ export const maximumReleaseGitRemoteTimeoutSeconds = 3600;
7
+
8
+ /**
9
+ * How long one remote inspection may take and how often a transient failure
10
+ * is retried. Remote inspection only reads refs, so repeating it is safe.
11
+ */
12
+ export interface IReleaseGitRemotePolicy {
13
+ /** Bound of one attempt. */
14
+ timeoutMs: number;
15
+ /** Wait before each retry; its length is the number of retries. */
16
+ retryDelaysMs: readonly number[];
17
+ }
18
+
19
+ /** Two retries, 5 s and 20 s apart: three attempts in all. */
20
+ const defaultRetryDelaysMs: readonly number[] = [5_000, 20_000];
21
+
22
+ export const createReleaseGitRemotePolicy = (
23
+ timeoutSecondsArg: number = defaultReleaseGitRemoteTimeoutSeconds,
24
+ ): IReleaseGitRemotePolicy => ({
25
+ timeoutMs: timeoutSecondsArg * 1000,
26
+ retryDelaysMs: defaultRetryDelaysMs,
27
+ });
28
+
29
+ /** The final attempt of a remote inspection and what it took to get there. */
30
+ export interface IReleaseGitRemoteResult extends plugins.smartshell.IExecResult {
31
+ attempts: number;
32
+ elapsedMs: number;
33
+ /** The final failure is one a later attempt could have overcome. */
34
+ transient: boolean;
35
+ }
36
+
37
+ /**
38
+ * A dropped or refused connection, or a gateway that gave up on a busy
39
+ * server, can succeed on the next attempt. Anything that names credentials,
40
+ * permissions or a missing repository cannot, so it is never retried.
41
+ */
42
+ const transientTransportPattern =
43
+ /connection reset|reset by peer|ECONNRESET|early EOF|unexpected disconnect|remote end hung up unexpectedly|connection timed out|operation timed out|connection closed by|kex_exchange_identification|broken pipe|RPC failed|returned error: 50[234]\b/i;
44
+ const permanentTransportPattern =
45
+ /authentication failed|permission denied|could not read (?:username|password)|terminal prompts disabled|access denied|returned error: 40[134]\b|repository not found|does not appear to be a git repository|not found/i;
46
+
47
+ export const isTransientGitRemoteFailure = (
48
+ resultArg: plugins.smartshell.IExecResult,
49
+ ): boolean => {
50
+ if (resultArg.exitCode === 0) return false;
51
+ if (resultArg.timedOut) return true;
52
+ return (
53
+ transientTransportPattern.test(resultArg.stderr) &&
54
+ !permanentTransportPattern.test(resultArg.stderr)
55
+ );
56
+ };
57
+
58
+ export interface IRunGitRemoteInspectionOptions {
59
+ smartshell: plugins.smartshell.Smartshell;
60
+ cwd: string;
61
+ /** `ls-remote` arguments, starting with `ls-remote`. */
62
+ args: string[];
63
+ env: NodeJS.ProcessEnv;
64
+ policy: IReleaseGitRemotePolicy;
65
+ }
66
+
67
+ /**
68
+ * Runs one read-only remote inspection under the policy's per-attempt bound,
69
+ * repeating it after a transient failure. The caller decides what the final
70
+ * answer means; this only makes a slow or flaky remote answer at all.
71
+ */
72
+ export const runGitRemoteInspection = async (
73
+ optionsArg: IRunGitRemoteInspectionOptions,
74
+ ): Promise<IReleaseGitRemoteResult> => {
75
+ const started = Date.now();
76
+ for (let attempt = 1; ; attempt++) {
77
+ const result = await optionsArg.smartshell.execSpawn(
78
+ "git",
79
+ optionsArg.args,
80
+ {
81
+ cwd: optionsArg.cwd,
82
+ env: optionsArg.env,
83
+ silent: true,
84
+ timeout: optionsArg.policy.timeoutMs,
85
+ timeoutKillGraceMs: 5_000,
86
+ },
87
+ );
88
+ const transient = isTransientGitRemoteFailure(result);
89
+ const retryDelayMs = optionsArg.policy.retryDelaysMs[attempt - 1];
90
+ if (!transient || retryDelayMs === undefined) {
91
+ return {
92
+ ...result,
93
+ attempts: attempt,
94
+ elapsedMs: Date.now() - started,
95
+ transient,
96
+ };
97
+ }
98
+ await new Promise((resolve) => setTimeout(resolve, retryDelayMs));
99
+ }
100
+ };
101
+
102
+ const formatSeconds = (msArg: number): string =>
103
+ `${Number((msArg / 1000).toFixed(1))} s`;
104
+
105
+ /** How the final attempt failed, and how long the inspection kept trying. */
106
+ export const describeGitRemoteFailure = (
107
+ resultArg: IReleaseGitRemoteResult,
108
+ policyArg: IReleaseGitRemotePolicy,
109
+ ): string => {
110
+ const failure = describeCommandFailure(resultArg, {
111
+ command: "git ls-remote",
112
+ timeoutMs: policyArg.timeoutMs,
113
+ });
114
+ return resultArg.attempts > 1
115
+ ? `${failure}; gave up after ${resultArg.attempts} attempts over ${formatSeconds(resultArg.elapsedMs)}`
116
+ : failure;
117
+ };
118
+
119
+ /**
120
+ * A remote inspection that failed. The message names the release step, the
121
+ * per-attempt bound, the attempts and the time spent; it never carries the
122
+ * destination URL, whose userinfo the command failure redacts.
123
+ */
124
+ export class ReleaseGitRemoteError extends Error {
125
+ public readonly step: string;
126
+ public readonly attempts: number;
127
+ public readonly elapsedMs: number;
128
+ public readonly timeoutMs: number;
129
+ public readonly transient: boolean;
130
+
131
+ constructor(
132
+ messageArg: string,
133
+ stepArg: string,
134
+ resultArg: IReleaseGitRemoteResult,
135
+ policyArg: IReleaseGitRemotePolicy,
136
+ ) {
137
+ super(
138
+ `${messageArg} Step: ${stepArg}. ${describeGitRemoteFailure(resultArg, policyArg)}`,
139
+ );
140
+ this.name = "ReleaseGitRemoteError";
141
+ this.step = stepArg;
142
+ this.attempts = resultArg.attempts;
143
+ this.elapsedMs = resultArg.elapsedMs;
144
+ this.timeoutMs = policyArg.timeoutMs;
145
+ this.transient = resultArg.transient;
146
+ }
147
+ }
@@ -3,6 +3,13 @@ import {
3
3
  formatCommandFailure,
4
4
  type IReleaseCommandFailureContext,
5
5
  } from "./helpers.commandfailure.js";
6
+ import {
7
+ ReleaseGitRemoteError,
8
+ createReleaseGitRemotePolicy,
9
+ runGitRemoteInspection,
10
+ type IReleaseGitRemotePolicy,
11
+ type IReleaseGitRemoteResult,
12
+ } from "./helpers.gitremote.js";
6
13
 
7
14
  const mainBranch = "main";
8
15
  const mainBranchRef = `refs/heads/${mainBranch}`;
@@ -27,6 +34,8 @@ export interface IReleaseBranchContext {
27
34
  pushUrl?: string;
28
35
  mergeRequested: boolean;
29
36
  planAncestryVerified: boolean;
37
+ /** Bound and retries of every remote inspection this release makes. */
38
+ gitRemotePolicy: IReleaseGitRemotePolicy;
30
39
  }
31
40
 
32
41
  export interface IIntegratedReleaseBranch {
@@ -44,6 +53,8 @@ export interface IInspectReleaseBranchOptions {
44
53
  pushTags?: boolean;
45
54
  mergeRequested: boolean;
46
55
  planMode: boolean;
56
+ /** Defaults to `release.targets.git.remoteTimeoutSeconds`' default. */
57
+ gitRemotePolicy?: IReleaseGitRemotePolicy;
47
58
  }
48
59
 
49
60
  type TSmartshell = plugins.smartshell.Smartshell;
@@ -475,28 +486,49 @@ const resolvePushUrl = async (
475
486
  export const isAbsentGitOid = (valueArg: string): boolean =>
476
487
  /^(?:0{40}|0{64})$/.test(valueArg);
477
488
 
489
+ /**
490
+ * Reads remote main from the push destination. `stepArg` names the release
491
+ * step in the error, so an unreachable remote says where the release stopped.
492
+ */
478
493
  const resolveRemoteMainOid = async (
479
494
  smartshellArg: TSmartshell,
480
- cwdArg: string,
495
+ contextArg: Pick<IReleaseBranchContext, "sourceCwd" | "gitRemotePolicy">,
481
496
  pushUrlArg: string,
497
+ stepArg: string,
482
498
  readOnlyArg = false,
483
499
  ): Promise<string> => {
484
- const result = await runGit(
485
- smartshellArg,
486
- cwdArg,
487
- ["ls-remote", "--exit-code", pushUrlArg, mainBranchRef],
488
- readOnlyArg,
489
- );
500
+ const inspect = (argsArg: string[]) =>
501
+ runGitRemoteInspection({
502
+ smartshell: smartshellArg,
503
+ cwd: contextArg.sourceCwd,
504
+ args: argsArg,
505
+ env: readOnlyArg ? readOnlyGitEnv : releaseGitEnv,
506
+ policy: contextArg.gitRemotePolicy,
507
+ });
508
+ const remoteFailure = (
509
+ resultArg: IReleaseGitRemoteResult,
510
+ messageArg: string,
511
+ ) =>
512
+ new ReleaseGitRemoteError(
513
+ messageArg,
514
+ stepArg,
515
+ resultArg,
516
+ contextArg.gitRemotePolicy,
517
+ );
518
+ const result = await inspect([
519
+ "ls-remote",
520
+ "--exit-code",
521
+ pushUrlArg,
522
+ mainBranchRef,
523
+ ]);
490
524
  if (result.exitCode === 2 && !result.stdout.trim()) {
491
- const allRefs = requireGitSuccess(
492
- await runGit(
493
- smartshellArg,
494
- cwdArg,
495
- ["ls-remote", pushUrlArg],
496
- readOnlyArg,
497
- ),
498
- "Unable to verify the empty Git push destination.",
499
- );
525
+ const allRefs = await inspect(["ls-remote", pushUrlArg]);
526
+ if (allRefs.exitCode !== 0) {
527
+ throw remoteFailure(
528
+ allRefs,
529
+ "Unable to verify the empty Git push destination.",
530
+ );
531
+ }
500
532
  if (allRefs.stdout.trim()) {
501
533
  throw new Error(
502
534
  "First release requires an empty Git remote; main is missing from a nonempty destination.",
@@ -505,7 +537,7 @@ const resolveRemoteMainOid = async (
505
537
  const format = requireGitSuccess(
506
538
  await runGit(
507
539
  smartshellArg,
508
- cwdArg,
540
+ contextArg.sourceCwd,
509
541
  ["rev-parse", "--show-object-format"],
510
542
  readOnlyArg,
511
543
  ),
@@ -516,10 +548,12 @@ const resolveRemoteMainOid = async (
516
548
  }
517
549
  return "0".repeat(format === "sha256" ? 64 : 40);
518
550
  }
519
- requireGitSuccess(
520
- result,
521
- "Unable to inspect main at the configured Git push destination.",
522
- );
551
+ if (result.exitCode !== 0) {
552
+ throw remoteFailure(
553
+ result,
554
+ "Unable to inspect main at the configured Git push destination.",
555
+ );
556
+ }
523
557
  const match = result.stdout
524
558
  .trim()
525
559
  .match(/^([0-9a-f]{40}|[0-9a-f]{64})\s+refs\/heads\/main$/i);
@@ -776,6 +810,8 @@ export async function inspectReleaseBranch(
776
810
  gitRemote: optionsArg.gitRemote,
777
811
  mergeRequested: optionsArg.mergeRequested,
778
812
  planAncestryVerified: false,
813
+ gitRemotePolicy:
814
+ optionsArg.gitRemotePolicy ?? createReleaseGitRemotePolicy(),
779
815
  };
780
816
 
781
817
  await verifyNoGitOperation(
@@ -859,8 +895,9 @@ export async function inspectReleaseBranch(
859
895
  );
860
896
  context.remoteMainOid = await resolveRemoteMainOid(
861
897
  optionsArg.smartshell,
862
- optionsArg.cwd,
898
+ context,
863
899
  context.pushUrl,
900
+ "release preflight",
864
901
  true,
865
902
  );
866
903
  if (isAbsentGitOid(context.remoteMainOid)) {
@@ -926,8 +963,9 @@ export async function prepareReleaseIntegration(
926
963
  }
927
964
  const remoteMainOid = await resolveRemoteMainOid(
928
965
  smartshellArg,
929
- contextArg.sourceCwd,
966
+ contextArg,
930
967
  contextArg.pushUrl,
968
+ "release preflight",
931
969
  );
932
970
  if (contextArg.remoteMainOid && remoteMainOid !== contextArg.remoteMainOid) {
933
971
  throw new Error(
@@ -965,8 +1003,9 @@ export async function prepareReleaseIntegration(
965
1003
  );
966
1004
  const verifiedRemoteMainOid = await resolveRemoteMainOid(
967
1005
  smartshellArg,
968
- contextArg.sourceCwd,
1006
+ contextArg,
969
1007
  contextArg.pushUrl,
1008
+ "release preflight",
970
1009
  );
971
1010
  if (verifiedRemoteMainOid !== remoteMainOid) {
972
1011
  throw new Error(
@@ -1033,8 +1072,9 @@ export async function revalidatePreparedReleaseBranch(
1033
1072
  }
1034
1073
  const currentRemoteMainOid = await resolveRemoteMainOid(
1035
1074
  smartshellArg,
1036
- contextArg.sourceCwd,
1075
+ contextArg,
1037
1076
  contextArg.pushUrl,
1077
+ "release preflight after tests",
1038
1078
  );
1039
1079
  if (currentRemoteMainOid !== contextArg.remoteMainOid) {
1040
1080
  throw new Error(
@@ -1139,8 +1179,9 @@ export async function verifyReleaseHistoryRetained(
1139
1179
  }
1140
1180
  const remoteMainOid = await resolveRemoteMainOid(
1141
1181
  smartshellArg,
1142
- contextArg.sourceCwd,
1182
+ contextArg,
1143
1183
  contextArg.pushUrl,
1184
+ "release history check",
1144
1185
  true,
1145
1186
  );
1146
1187
  if (isAbsentGitOid(remoteMainOid)) {
@@ -1209,8 +1250,9 @@ export async function revalidateReleasePublicationState(
1209
1250
  }
1210
1251
  const currentRemoteMainOid = await resolveRemoteMainOid(
1211
1252
  smartshellArg,
1212
- contextArg.sourceCwd,
1253
+ contextArg,
1213
1254
  contextArg.pushUrl,
1255
+ "publication state check",
1214
1256
  );
1215
1257
  if (currentRemoteMainOid !== expectedRemoteMainOidArg) {
1216
1258
  throw new Error(
@@ -1377,8 +1419,9 @@ export async function integrateReleaseBranch(
1377
1419
  }
1378
1420
  const currentRemoteMainOid = await resolveRemoteMainOid(
1379
1421
  smartshellArg,
1380
- contextArg.sourceCwd,
1422
+ contextArg,
1381
1423
  contextArg.pushUrl,
1424
+ "main integration",
1382
1425
  );
1383
1426
  if (currentRemoteMainOid !== contextArg.remoteMainOid) {
1384
1427
  throw new Error(
@@ -1506,8 +1549,9 @@ export async function integrateReleaseBranch(
1506
1549
  try {
1507
1550
  remoteAfterPush = await resolveRemoteMainOid(
1508
1551
  smartshellArg,
1509
- contextArg.sourceCwd,
1552
+ contextArg,
1510
1553
  contextArg.pushUrl,
1554
+ "main integration",
1511
1555
  );
1512
1556
  } catch {
1513
1557
  remoteAfterPush = undefined;
@@ -1542,8 +1586,9 @@ export async function integrateReleaseBranch(
1542
1586
  try {
1543
1587
  pushedRemoteMainOid = await resolveRemoteMainOid(
1544
1588
  smartshellArg,
1545
- contextArg.sourceCwd,
1589
+ contextArg,
1546
1590
  contextArg.pushUrl,
1591
+ "main integration",
1547
1592
  );
1548
1593
  } catch {
1549
1594
  const rollbackState = await rollbackLocalMain(
@@ -20,6 +20,10 @@ import {
20
20
  } from "./helpers.npmartifact.js";
21
21
  import { getReleaseNpmPublicationOrder } from "./helpers.npmpackages.js";
22
22
  import { formatCommandFailure } from "./helpers.commandfailure.js";
23
+ import {
24
+ ReleaseGitRemoteError,
25
+ runGitRemoteInspection,
26
+ } from "./helpers.gitremote.js";
23
27
  import {
24
28
  canonicalReleaseJson,
25
29
  type IReleaseQualificationRequest,
@@ -167,13 +171,27 @@ export const assertPackageReleaseRecovery = async (
167
171
  export const assertRecoveryUnpublished = async (
168
172
  options: IReleasePreparationRecovery,
169
173
  ): Promise<void> => {
170
- const output = await git(options, [
171
- "ls-remote",
172
- options.branch.pushUrl!,
173
- `refs/tags/v${options.version}`,
174
- `refs/tags/v${options.version}^{}`,
175
- ]);
176
- if (output)
174
+ const policy = options.branch.gitRemotePolicy;
175
+ const remoteTags = await runGitRemoteInspection({
176
+ smartshell: options.smartshell,
177
+ cwd: options.branch.sourceCwd,
178
+ args: [
179
+ "ls-remote",
180
+ options.branch.pushUrl!,
181
+ `refs/tags/v${options.version}`,
182
+ `refs/tags/v${options.version}^{}`,
183
+ ],
184
+ env: releaseGitEnv,
185
+ policy,
186
+ });
187
+ if (remoteTags.exitCode !== 0)
188
+ throw new ReleaseGitRemoteError(
189
+ "Unable to inspect the release tag at the configured Git push destination.",
190
+ "release recovery",
191
+ remoteTags,
192
+ policy,
193
+ );
194
+ if (remoteTags.stdout.trim())
177
195
  throw new Error(
178
196
  "Recovery cannot adopt an existing remote release tag. Use its original journal.",
179
197
  );
@@ -19,6 +19,7 @@ import {
19
19
  GiteaAssetsClient,
20
20
  GiteaAssetConflictError,
21
21
  validateGiteaAssets,
22
+ type IGiteaAssetTransferLimits,
22
23
  } from "./helpers.giteaassets.js";
23
24
  import { assertGiteaAssetsGitDestination } from "../helpers.workflow.js";
24
25
  import {
@@ -36,6 +37,12 @@ import {
36
37
  } from "./helpers.npmartifact.js";
37
38
  import { isAbsentGitOid, releaseGitEnv } from "./helpers.releasebranch.js";
38
39
  import { describeCommandFailure } from "./helpers.commandfailure.js";
40
+ import {
41
+ createReleaseGitRemotePolicy,
42
+ describeGitRemoteFailure,
43
+ runGitRemoteInspection,
44
+ type IReleaseGitRemotePolicy,
45
+ } from "./helpers.gitremote.js";
39
46
  import {
40
47
  TsdockerReleaseCommandError,
41
48
  TsdockerReleaseRequestCleanupError,
@@ -49,7 +56,6 @@ import {
49
56
  type TReleasePromotionEvidence,
50
57
  } from "./helpers.tsdockerprotocol.js";
51
58
 
52
- const gitProbeTimeoutMs = 60_000;
53
59
  const gitPushTimeoutMs = 5 * 60_000;
54
60
 
55
61
  export interface IBuildReleaseGitPushArgsOptions {
@@ -121,6 +127,10 @@ export interface IReleasePublicationOptions {
121
127
  /** Waiting budget for one accepted npm target before resume takes over. */
122
128
  npmVerificationWindowMs?: number;
123
129
  tsdocker?: ITsdockerReleaseClient;
130
+ /** Transfer bounds for the Gitea client built from the journal's destination. */
131
+ giteaAssetTransfer?: IGiteaAssetTransferLimits;
132
+ /** Bound and retries of the Git target's remote inspection. */
133
+ gitRemotePolicy?: IReleaseGitRemotePolicy;
124
134
  giteaAssets?: Pick<
125
135
  GiteaAssetsClient,
126
136
  | "preflight"
@@ -311,30 +321,29 @@ const recoverPublishingTarget = async (
311
321
  };
312
322
 
313
323
  const inspectRemoteRelease = async (
314
- smartshellArg: plugins.smartshell.Smartshell,
315
- cwdArg: string,
324
+ optionsArg: IReleasePublicationOptions,
316
325
  destinationArg: string,
317
326
  journalArg: TReleaseJournal,
318
327
  ): Promise<IGitProbeResult> => {
319
328
  const tagRef = `refs/tags/${journalArg.release.tag}`;
320
- const result = await smartshellArg.execSpawn(
321
- "git",
322
- ["ls-remote", destinationArg, "refs/heads/main", tagRef, `${tagRef}^{}`],
323
- {
324
- cwd: cwdArg,
325
- env: releaseGitEnv,
326
- silent: true,
327
- timeout: gitProbeTimeoutMs,
328
- timeoutKillGraceMs: 5_000,
329
- },
330
- );
329
+ const policy = optionsArg.gitRemotePolicy ?? createReleaseGitRemotePolicy();
330
+ const result = await runGitRemoteInspection({
331
+ smartshell: optionsArg.smartshell,
332
+ cwd: optionsArg.cwd,
333
+ args: [
334
+ "ls-remote",
335
+ destinationArg,
336
+ "refs/heads/main",
337
+ tagRef,
338
+ `${tagRef}^{}`,
339
+ ],
340
+ env: releaseGitEnv,
341
+ policy,
342
+ });
331
343
  if (result.exitCode !== 0) {
332
344
  return {
333
345
  status: "inconclusive",
334
- failure: describeCommandFailure(result, {
335
- command: "git ls-remote",
336
- timeoutMs: gitProbeTimeoutMs,
337
- }),
346
+ failure: `Step: target.git. ${describeGitRemoteFailure(result, policy)}`,
338
347
  };
339
348
  }
340
349
  const refs = new Map<string, string>();
@@ -381,12 +390,7 @@ const executeGitTarget = async (
381
390
  }
382
391
 
383
392
  let journal = journalArg;
384
- let probe = await inspectRemoteRelease(
385
- optionsArg.smartshell,
386
- optionsArg.cwd,
387
- optionsArg.pushUrl,
388
- journal,
389
- );
393
+ let probe = await inspectRemoteRelease(optionsArg, optionsArg.pushUrl, journal);
390
394
  if (journal.git.state === "verified") {
391
395
  if (probe.status === "exact") {
392
396
  await optionsArg.ensurePublicationState(journal.release.mainOid);
@@ -454,12 +458,7 @@ const executeGitTarget = async (
454
458
  "Git release target is in conflict and cannot resume automatically.",
455
459
  );
456
460
  }
457
- probe = await inspectRemoteRelease(
458
- optionsArg.smartshell,
459
- optionsArg.cwd,
460
- optionsArg.pushUrl,
461
- journal,
462
- );
461
+ probe = await inspectRemoteRelease(optionsArg, optionsArg.pushUrl, journal);
463
462
  if (probe.status === "exact") {
464
463
  journal = await markUnclaimedTarget(
465
464
  optionsArg.store,
@@ -520,12 +519,7 @@ const executeGitTarget = async (
520
519
  timeoutKillGraceMs: 5_000,
521
520
  },
522
521
  );
523
- probe = await inspectRemoteRelease(
524
- optionsArg.smartshell,
525
- optionsArg.cwd,
526
- optionsArg.pushUrl,
527
- journal,
528
- );
522
+ probe = await inspectRemoteRelease(optionsArg, optionsArg.pushUrl, journal);
529
523
  if (probe.status === "exact") {
530
524
  journal = await finishPublishingTarget(
531
525
  optionsArg.store,
@@ -1561,7 +1555,8 @@ const executeGiteaTarget = async (
1561
1555
  options: IReleasePublicationOptions,
1562
1556
  journalArg: TReleaseJournal,
1563
1557
  selector: TReleaseTargetSelector,
1564
- inspect: () => Promise<boolean>,
1558
+ /** `verifyBytes` is false only for a target the journal already recorded as verified. */
1559
+ inspect: (verifyBytes: boolean) => Promise<boolean>,
1565
1560
  publish: () => Promise<void>,
1566
1561
  onVerified?: (target: IReleaseTargetStatus) => void,
1567
1562
  ): Promise<TReleaseJournal> => {
@@ -1590,7 +1585,9 @@ const executeGiteaTarget = async (
1590
1585
  };
1591
1586
  let present: boolean;
1592
1587
  try {
1593
- present = await inspect();
1588
+ // A recorded verification already proved these bytes; the complete-set
1589
+ // verification before npm downloads every attachment once more.
1590
+ present = await inspect(status.state !== "verified");
1594
1591
  } catch (error) {
1595
1592
  if (error instanceof GiteaAssetConflictError)
1596
1593
  await mark("conflict", "destination-conflict");
@@ -1625,7 +1622,7 @@ const executeGiteaTarget = async (
1625
1622
  publicationError = error;
1626
1623
  }
1627
1624
  try {
1628
- present = await inspect();
1625
+ present = await inspect(true);
1629
1626
  } catch (error) {
1630
1627
  await mark(
1631
1628
  error instanceof GiteaAssetConflictError ? "conflict" : "failed",
@@ -1647,8 +1644,9 @@ const executeGiteaTarget = async (
1647
1644
  ? "command-failed"
1648
1645
  : "verification-inconclusive",
1649
1646
  );
1647
+ // Client errors carry no URL or credential; keep the stall/timeout cause visible.
1650
1648
  throw new Error(
1651
- "Gitea publication could not be verified; npm publication remains blocked. Inspect the retained journal before resuming.",
1649
+ `Gitea publication could not be verified; npm publication remains blocked. Inspect the retained journal before resuming.${publicationError instanceof Error ? ` Attempt: ${publicationError.message}` : ""}`,
1652
1650
  );
1653
1651
  };
1654
1652
 
@@ -1686,8 +1684,12 @@ const executeGiteaAssets = async (
1686
1684
  options,
1687
1685
  journal,
1688
1686
  { kind: "gitea-asset", name: asset.name },
1689
- async () => {
1690
- const inspection = await client.inspectAssets(releaseId!, expected);
1687
+ async (verifyBytes) => {
1688
+ const inspection = await client.inspectAssets(
1689
+ releaseId!,
1690
+ expected,
1691
+ verifyBytes ? [asset] : [],
1692
+ );
1691
1693
  return inspection.present.some((entry) => entry.name === asset.name);
1692
1694
  },
1693
1695
  async () => {
@@ -1745,6 +1747,7 @@ export const executeReleasePublication = async (
1745
1747
  `Gitea assets require the configured credential in ${tokenEnv}.`,
1746
1748
  );
1747
1749
  giteaClient = new GiteaAssetsClient({
1750
+ ...optionsArg.giteaAssetTransfer,
1748
1751
  destination,
1749
1752
  token,
1750
1753
  tag: journal.release.tag,