type-git 0.3.0-alpha.2 → 0.3.0-alpha.3
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.
- package/README.md +14 -0
- package/dist/adapters/bun/index.cjs +2 -2
- package/dist/adapters/bun/index.cjs.map +1 -1
- package/dist/adapters/bun/index.d.cts +1 -1
- package/dist/adapters/bun/index.d.ts +1 -1
- package/dist/adapters/bun/index.js +2 -2
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +35 -2
- package/dist/adapters/deno/index.cjs.map +1 -1
- package/dist/adapters/deno/index.d.cts +1 -1
- package/dist/adapters/deno/index.d.ts +1 -1
- package/dist/adapters/deno/index.js +35 -2
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +120 -23
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +38 -4
- package/dist/adapters/node/index.d.ts +38 -4
- package/dist/adapters/node/index.js +120 -23
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-sSzx9O1u.d.cts → adapters-CZ8wj9Kr.d.cts} +2 -0
- package/dist/{adapters-sSzx9O1u.d.ts → adapters-CZ8wj9Kr.d.ts} +2 -0
- package/dist/index.cjs +120 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +120 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Z as AddOpts, bC as BareRepo, a0 as BranchCreateOpts, a1 as BranchDeleteOpts, _ as BranchInfo, bh as BranchOperations, $ as BranchOpts, a2 as CheckoutBranchOpts, a4 as CheckoutOpts, a3 as CheckoutPathOpts, am as CherryPickOpts, an as CleanOpts, v as CliRunner, w as CliRunnerOptions, x as CloneOpts, U as Commit, a5 as CommitOpts, a6 as CommitResult, bt as ConfigEntry, bu as ConfigGetOpts, by as ConfigKey, bw as ConfigListOpts, bz as ConfigOperations, bx as ConfigSchema, bv as ConfigSetOpts, C as CreateGitOptions, a8 as DiffEntry, a7 as DiffOpts, a9 as DiffResult, W as FetchOpts, X as ForceWithLeaseOpts, G as GIT_LOG_FORMAT, H as Git, b as GitProgressInfo, E as GlobalConfigListOpts, F as GlobalConfigOperations, A as GlobalLfsInstallOpts, D as GlobalLfsOperations, B as GlobalLfsUninstallOpts, I as InitOpts, L as LEGACY_GIT_VERSION, a_ as LfsCheckoutOpts, b2 as LfsEnvInfo, bg as LfsExtraOperations, aP as LfsFetchOpts, aS as LfsFileEntry, aW as LfsLockEntry, aX as LfsLockOpts, aZ as LfsLocksOpts, aT as LfsLsFilesOpts, b1 as LfsMigrateExportOpts, b0 as LfsMigrateImportOpts, a$ as LfsMigrateInfoOpts, bf as LfsOperations, b5 as LfsPreDownloadOpts, b6 as LfsPreDownloadResult, b3 as LfsPreUploadOpts, b4 as LfsPreUploadResult, e as LfsProgressInfo, aO as LfsPruneOpts, aL as LfsPullOpts, aM as LfsPushOpts, aK as LfsStatus, aN as LfsStatusOpts, aU as LfsTrackEntry, aV as LfsTrackOpts, aY as LfsUnlockOpts, V as LogOpts, y as LsRemoteOpts, f as LsRemoteRef, z as LsRemoteResult, N as LsTreeEntry, g as LsTreeObjectType, O as LsTreeOpts, M as MIN_GIT_VERSION, aa as MergeOpts, ab as MergeResult, ao as MvOpts, NodeExecAdapter, NodeFsAdapter, P as ParsedCommit, h as ParsedLsTreeEntry, i as ParsedWorktree, j as PorcelainV2Entry, ac as PullOpts, Y as PushOpts, ap as RebaseOpts, bl as RemoteAddOpts, bk as RemoteInfo, bs as RemoteOperations, bo as RemotePruneOpts, bq as RemoteSetBranchesOpts, bm as RemoteSetHeadOpts, bn as RemoteShowOpts, bp as RemoteUpdateOpts, br as RemoteUrlOpts, R as RepoBase, aQ as RepoLfsInstallOpts, aR as RepoLfsUninstallOpts, J as RepoLsRemoteOpts, K as RepoLsRemoteResult, ad as ResetOpts, aq as RestoreOpts, au as RevParseBooleanQuery, av as RevParseListOpts, aw as RevParseListQuery, ay as RevParseOtherQuery, az as RevParsePathFormat, aA as RevParsePathOpts, at as RevParsePathQuery, ax as RevParseRefOpts, ar as RevertOpts, ae as RmOpts, as as ShowOpts, ah as StashApplyOpts, af as StashEntry, bi as StashOperations, ag as StashPushOpts, S as StatusEntry, T as StatusOpts, Q as StatusPorcelain, aC as SubmoduleAddOpts, aD as SubmoduleDeinitOpts, aG as SubmoduleForeachOpts, aJ as SubmoduleInfo, bA as SubmoduleOperations, aB as SubmoduleOpts, aI as SubmoduleSetBranchOpts, aE as SubmoduleStatusOpts, aF as SubmoduleSummaryOpts, aH as SubmoduleSyncOpts, ai as SwitchOpts, al as TagCreateOpts, aj as TagInfo, ak as TagListOpts, bj as TagOperations, TypeGit, TypeGitOptions, b7 as Worktree, b8 as WorktreeAddOpts, bd as WorktreeLockOpts, bb as WorktreeMoveOpts, be as WorktreeOperations, ba as WorktreePruneOpts, b9 as WorktreeRemoveOpts, bc as WorktreeRepairOpts, bB as WorktreeRepo, c as createGit, a as createGitSync, createNodeAdapters, d as detectErrorCategory, p as parseGitLog, k as parseGitProgress, l as parseJson, m as parseKeyValue, n as parseLfsProgress, o as parseLines, q as parseLsRemote, r as parseLsTree, s as parsePorcelainV2, t as parseRecords, u as parseWorktreeList } from './adapters/node/index.cjs';
|
|
2
|
-
export { l as AdapterFactory, A as AuditConfig, H as AuditEvent, B as AuditEventEnd, z as AuditEventStart, C as Capabilities, v as CommandSpec, x as Credential, y as CredentialConfig, w as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, m as EnvAllowlistAdjustment, i as EnvInheritance, n as EnvInheritancePredicate, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, t as GitArgumentError, k as GitError, G as GitErrorCategory, s as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, q as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, u as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, I as TraceEvent, p as isNonEmpty, o as nonEmpty, r as resolveInheritedEnv } from './adapters-
|
|
2
|
+
export { l as AdapterFactory, A as AuditConfig, H as AuditEvent, B as AuditEventEnd, z as AuditEventStart, C as Capabilities, v as CommandSpec, x as Credential, y as CredentialConfig, w as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, m as EnvAllowlistAdjustment, i as EnvInheritance, n as EnvInheritancePredicate, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, t as GitArgumentError, k as GitError, G as GitErrorCategory, s as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, q as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, u as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, I as TraceEvent, p as isNonEmpty, o as nonEmpty, r as resolveInheritedEnv } from './adapters-CZ8wj9Kr.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Z as AddOpts, bC as BareRepo, a0 as BranchCreateOpts, a1 as BranchDeleteOpts, _ as BranchInfo, bh as BranchOperations, $ as BranchOpts, a2 as CheckoutBranchOpts, a4 as CheckoutOpts, a3 as CheckoutPathOpts, am as CherryPickOpts, an as CleanOpts, v as CliRunner, w as CliRunnerOptions, x as CloneOpts, U as Commit, a5 as CommitOpts, a6 as CommitResult, bt as ConfigEntry, bu as ConfigGetOpts, by as ConfigKey, bw as ConfigListOpts, bz as ConfigOperations, bx as ConfigSchema, bv as ConfigSetOpts, C as CreateGitOptions, a8 as DiffEntry, a7 as DiffOpts, a9 as DiffResult, W as FetchOpts, X as ForceWithLeaseOpts, G as GIT_LOG_FORMAT, H as Git, b as GitProgressInfo, E as GlobalConfigListOpts, F as GlobalConfigOperations, A as GlobalLfsInstallOpts, D as GlobalLfsOperations, B as GlobalLfsUninstallOpts, I as InitOpts, L as LEGACY_GIT_VERSION, a_ as LfsCheckoutOpts, b2 as LfsEnvInfo, bg as LfsExtraOperations, aP as LfsFetchOpts, aS as LfsFileEntry, aW as LfsLockEntry, aX as LfsLockOpts, aZ as LfsLocksOpts, aT as LfsLsFilesOpts, b1 as LfsMigrateExportOpts, b0 as LfsMigrateImportOpts, a$ as LfsMigrateInfoOpts, bf as LfsOperations, b5 as LfsPreDownloadOpts, b6 as LfsPreDownloadResult, b3 as LfsPreUploadOpts, b4 as LfsPreUploadResult, e as LfsProgressInfo, aO as LfsPruneOpts, aL as LfsPullOpts, aM as LfsPushOpts, aK as LfsStatus, aN as LfsStatusOpts, aU as LfsTrackEntry, aV as LfsTrackOpts, aY as LfsUnlockOpts, V as LogOpts, y as LsRemoteOpts, f as LsRemoteRef, z as LsRemoteResult, N as LsTreeEntry, g as LsTreeObjectType, O as LsTreeOpts, M as MIN_GIT_VERSION, aa as MergeOpts, ab as MergeResult, ao as MvOpts, NodeExecAdapter, NodeFsAdapter, P as ParsedCommit, h as ParsedLsTreeEntry, i as ParsedWorktree, j as PorcelainV2Entry, ac as PullOpts, Y as PushOpts, ap as RebaseOpts, bl as RemoteAddOpts, bk as RemoteInfo, bs as RemoteOperations, bo as RemotePruneOpts, bq as RemoteSetBranchesOpts, bm as RemoteSetHeadOpts, bn as RemoteShowOpts, bp as RemoteUpdateOpts, br as RemoteUrlOpts, R as RepoBase, aQ as RepoLfsInstallOpts, aR as RepoLfsUninstallOpts, J as RepoLsRemoteOpts, K as RepoLsRemoteResult, ad as ResetOpts, aq as RestoreOpts, au as RevParseBooleanQuery, av as RevParseListOpts, aw as RevParseListQuery, ay as RevParseOtherQuery, az as RevParsePathFormat, aA as RevParsePathOpts, at as RevParsePathQuery, ax as RevParseRefOpts, ar as RevertOpts, ae as RmOpts, as as ShowOpts, ah as StashApplyOpts, af as StashEntry, bi as StashOperations, ag as StashPushOpts, S as StatusEntry, T as StatusOpts, Q as StatusPorcelain, aC as SubmoduleAddOpts, aD as SubmoduleDeinitOpts, aG as SubmoduleForeachOpts, aJ as SubmoduleInfo, bA as SubmoduleOperations, aB as SubmoduleOpts, aI as SubmoduleSetBranchOpts, aE as SubmoduleStatusOpts, aF as SubmoduleSummaryOpts, aH as SubmoduleSyncOpts, ai as SwitchOpts, al as TagCreateOpts, aj as TagInfo, ak as TagListOpts, bj as TagOperations, TypeGit, TypeGitOptions, b7 as Worktree, b8 as WorktreeAddOpts, bd as WorktreeLockOpts, bb as WorktreeMoveOpts, be as WorktreeOperations, ba as WorktreePruneOpts, b9 as WorktreeRemoveOpts, bc as WorktreeRepairOpts, bB as WorktreeRepo, c as createGit, a as createGitSync, createNodeAdapters, d as detectErrorCategory, p as parseGitLog, k as parseGitProgress, l as parseJson, m as parseKeyValue, n as parseLfsProgress, o as parseLines, q as parseLsRemote, r as parseLsTree, s as parsePorcelainV2, t as parseRecords, u as parseWorktreeList } from './adapters/node/index.js';
|
|
2
|
-
export { l as AdapterFactory, A as AuditConfig, H as AuditEvent, B as AuditEventEnd, z as AuditEventStart, C as Capabilities, v as CommandSpec, x as Credential, y as CredentialConfig, w as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, m as EnvAllowlistAdjustment, i as EnvInheritance, n as EnvInheritancePredicate, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, t as GitArgumentError, k as GitError, G as GitErrorCategory, s as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, q as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, u as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, I as TraceEvent, p as isNonEmpty, o as nonEmpty, r as resolveInheritedEnv } from './adapters-
|
|
2
|
+
export { l as AdapterFactory, A as AuditConfig, H as AuditEvent, B as AuditEventEnd, z as AuditEventStart, C as Capabilities, v as CommandSpec, x as Credential, y as CredentialConfig, w as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, m as EnvAllowlistAdjustment, i as EnvInheritance, n as EnvInheritancePredicate, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, t as GitArgumentError, k as GitError, G as GitErrorCategory, s as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, q as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, u as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, I as TraceEvent, p as isNonEmpty, o as nonEmpty, r as resolveInheritedEnv } from './adapters-CZ8wj9Kr.js';
|
package/dist/index.js
CHANGED
|
@@ -833,6 +833,7 @@ var CliRunner = class _CliRunner {
|
|
|
833
833
|
result = await this.exec.spawn(
|
|
834
834
|
{
|
|
835
835
|
argv,
|
|
836
|
+
stdin: opts?.stdin,
|
|
836
837
|
env,
|
|
837
838
|
// The env above is already fully resolved (including any inherited variables),
|
|
838
839
|
// so the adapter must not merge the parent environment on top of it.
|
|
@@ -1688,7 +1689,53 @@ var BareRepoImpl = class {
|
|
|
1688
1689
|
}
|
|
1689
1690
|
};
|
|
1690
1691
|
|
|
1692
|
+
// src/internal/concurrency.ts
|
|
1693
|
+
async function runWithConcurrency(items, run, options) {
|
|
1694
|
+
const { concurrency, warmupCount = 0 } = options;
|
|
1695
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
1696
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
1697
|
+
}
|
|
1698
|
+
if (!Number.isInteger(warmupCount) || warmupCount < 0) {
|
|
1699
|
+
throw new RangeError(`warmupCount must be a non-negative integer, got: ${warmupCount}`);
|
|
1700
|
+
}
|
|
1701
|
+
const results = new Array(items.length);
|
|
1702
|
+
let nextIndex = 0;
|
|
1703
|
+
let failed = false;
|
|
1704
|
+
let firstError;
|
|
1705
|
+
const runOne = async (index) => {
|
|
1706
|
+
try {
|
|
1707
|
+
const item = items[index];
|
|
1708
|
+
results[index] = await run(item, index);
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
if (!failed) {
|
|
1711
|
+
failed = true;
|
|
1712
|
+
firstError = error;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
const warmupEnd = Math.min(warmupCount, items.length);
|
|
1717
|
+
while (nextIndex < warmupEnd && !failed) {
|
|
1718
|
+
await runOne(nextIndex++);
|
|
1719
|
+
}
|
|
1720
|
+
if (!failed && nextIndex < items.length) {
|
|
1721
|
+
const worker = async () => {
|
|
1722
|
+
while (!failed && nextIndex < items.length) {
|
|
1723
|
+
await runOne(nextIndex++);
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
const workerCount = Math.min(concurrency, items.length - nextIndex);
|
|
1727
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
1728
|
+
}
|
|
1729
|
+
if (failed) {
|
|
1730
|
+
throw firstError;
|
|
1731
|
+
}
|
|
1732
|
+
return results;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1691
1735
|
// src/impl/worktree-repo-impl.ts
|
|
1736
|
+
var PRE_UPLOAD_DEFAULT_BATCH_SIZE = 200;
|
|
1737
|
+
var PRE_UPLOAD_DEFAULT_CONCURRENCY = 4;
|
|
1738
|
+
var PRE_UPLOAD_WARMUP_BATCH_COUNT = 1;
|
|
1692
1739
|
var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
1693
1740
|
workdir;
|
|
1694
1741
|
runner;
|
|
@@ -2437,27 +2484,30 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2437
2484
|
if (this._lfsMode === "disabled") {
|
|
2438
2485
|
return;
|
|
2439
2486
|
}
|
|
2487
|
+
if (opts?.stdin && opts.objectId === void 0 && !opts.ref) {
|
|
2488
|
+
throw new TypeError("lfs.push with stdin requires objectId or ref");
|
|
2489
|
+
}
|
|
2440
2490
|
const args = ["lfs", "push"];
|
|
2441
2491
|
if (opts?.dryRun) {
|
|
2442
2492
|
args.push("--dry-run");
|
|
2443
2493
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
} else {
|
|
2450
|
-
args.push("--all");
|
|
2494
|
+
const oids = opts?.objectId !== void 0 ? Array.isArray(opts.objectId) ? opts.objectId : [opts.objectId] : void 0;
|
|
2495
|
+
if (oids?.length === 0 && !opts?.stdin) {
|
|
2496
|
+
throw new TypeError(
|
|
2497
|
+
"lfs.push with objectId requires at least one OID unless stdin is enabled"
|
|
2498
|
+
);
|
|
2451
2499
|
}
|
|
2452
|
-
|
|
2453
|
-
|
|
2500
|
+
args.push(oids ? "--object-id" : "--all");
|
|
2501
|
+
args.push(opts?.remote ?? "origin");
|
|
2502
|
+
const values = oids ?? (opts?.ref ? [opts.ref] : []);
|
|
2503
|
+
if (opts?.stdin) {
|
|
2504
|
+
args.push("--stdin");
|
|
2454
2505
|
} else {
|
|
2455
|
-
args.push(
|
|
2456
|
-
}
|
|
2457
|
-
if (opts?.ref) {
|
|
2458
|
-
args.push(opts.ref);
|
|
2506
|
+
args.push(...values);
|
|
2459
2507
|
}
|
|
2460
2508
|
await this.runner.runOrThrow(this.context, args, {
|
|
2509
|
+
stdin: opts?.stdin ? values.length > 0 ? `${values.join("\n")}
|
|
2510
|
+
` : "" : void 0,
|
|
2461
2511
|
signal: opts?.signal,
|
|
2462
2512
|
onProgress: opts?.onProgress,
|
|
2463
2513
|
onLfsProgress: opts?.onLfsProgress
|
|
@@ -2496,12 +2546,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2496
2546
|
* Pre-upload LFS objects before commit/push (2-phase commit pattern)
|
|
2497
2547
|
*
|
|
2498
2548
|
* This allows uploading LFS objects to the remote before creating a commit,
|
|
2499
|
-
* ensuring reliable large file handling. Objects are batched to
|
|
2500
|
-
*
|
|
2549
|
+
* ensuring reliable large file handling. Objects are batched to stay within
|
|
2550
|
+
* command-line length limits, and batches run with bounded concurrency to
|
|
2551
|
+
* overlap per-invocation fixed costs with other batches' transfers.
|
|
2552
|
+
*
|
|
2553
|
+
* Failure handling: once a batch fails, no new batch is started (in-flight
|
|
2554
|
+
* batches are awaited), and the objects of failed and unstarted batches are
|
|
2555
|
+
* reported in `skippedCount`. The first batch always runs alone before the
|
|
2556
|
+
* remaining batches widen to the concurrency limit, so a failure common to
|
|
2557
|
+
* all batches costs a single round-trip.
|
|
2501
2558
|
*
|
|
2502
2559
|
* Usage pattern:
|
|
2503
2560
|
* 1. Stage changes: git add
|
|
2504
|
-
* 2. Pre-upload LFS: await repo.
|
|
2561
|
+
* 2. Pre-upload LFS: await repo.lfsExtra.preUpload()
|
|
2505
2562
|
* 3. Commit: git commit
|
|
2506
2563
|
* 4. Push refs: git push (only refs, objects already uploaded)
|
|
2507
2564
|
*/
|
|
@@ -2510,7 +2567,14 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2510
2567
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2511
2568
|
}
|
|
2512
2569
|
const remote = opts?.remote ?? "origin";
|
|
2513
|
-
const batchSize = opts?.batchSize ??
|
|
2570
|
+
const batchSize = opts?.batchSize ?? PRE_UPLOAD_DEFAULT_BATCH_SIZE;
|
|
2571
|
+
const concurrency = opts?.concurrency ?? PRE_UPLOAD_DEFAULT_CONCURRENCY;
|
|
2572
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2573
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2574
|
+
}
|
|
2575
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
2576
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
2577
|
+
}
|
|
2514
2578
|
let oids;
|
|
2515
2579
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2516
2580
|
oids = opts.oids;
|
|
@@ -2535,18 +2599,24 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2535
2599
|
if (oids.length === 0) {
|
|
2536
2600
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2537
2601
|
}
|
|
2602
|
+
const batches = [];
|
|
2603
|
+
for (let i = 0; i < oids.length; i += batchSize) {
|
|
2604
|
+
batches.push(oids.slice(i, i + batchSize));
|
|
2605
|
+
}
|
|
2538
2606
|
let uploadedCount = 0;
|
|
2539
2607
|
let uploadedBytes = 0;
|
|
2540
2608
|
let skippedCount = 0;
|
|
2541
|
-
|
|
2542
|
-
|
|
2609
|
+
let attemptedCount = 0;
|
|
2610
|
+
const batchFailedStop = new Error("lfs pre-upload batch failed");
|
|
2611
|
+
const pushBatch = async (batch) => {
|
|
2543
2612
|
const args = ["lfs", "push", remote, "--object-id", ...batch];
|
|
2544
2613
|
const result = await this.runner.run(this.context, args, {
|
|
2545
2614
|
signal: opts?.signal,
|
|
2546
2615
|
onProgress: opts?.onProgress,
|
|
2547
2616
|
onLfsProgress: opts?.onLfsProgress
|
|
2548
2617
|
});
|
|
2549
|
-
|
|
2618
|
+
attemptedCount += batch.length;
|
|
2619
|
+
if (result.exitCode === 0 && !result.aborted) {
|
|
2550
2620
|
uploadedCount += batch.length;
|
|
2551
2621
|
const bytesMatch = result.stderr.match(
|
|
2552
2622
|
/Uploading LFS objects:.*?\((\d+(?:\.\d+)?)\s*([KMG]?B)/i
|
|
@@ -2566,7 +2636,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2566
2636
|
}
|
|
2567
2637
|
} else {
|
|
2568
2638
|
skippedCount += batch.length;
|
|
2639
|
+
throw batchFailedStop;
|
|
2569
2640
|
}
|
|
2641
|
+
};
|
|
2642
|
+
try {
|
|
2643
|
+
await runWithConcurrency(batches, pushBatch, {
|
|
2644
|
+
concurrency,
|
|
2645
|
+
warmupCount: PRE_UPLOAD_WARMUP_BATCH_COUNT
|
|
2646
|
+
});
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
if (error !== batchFailedStop) {
|
|
2649
|
+
throw error;
|
|
2650
|
+
}
|
|
2651
|
+
skippedCount += oids.length - attemptedCount;
|
|
2570
2652
|
}
|
|
2571
2653
|
return { uploadedCount, uploadedBytes, skippedCount };
|
|
2572
2654
|
}
|
|
@@ -2578,7 +2660,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2578
2660
|
*
|
|
2579
2661
|
* Usage pattern:
|
|
2580
2662
|
* 1. Fetch refs: git fetch
|
|
2581
|
-
* 2. Pre-download LFS: await repo.
|
|
2663
|
+
* 2. Pre-download LFS: await repo.lfsExtra.preDownload({ ref: 'origin/feature' })
|
|
2582
2664
|
* 3. Checkout: git checkout feature
|
|
2583
2665
|
*/
|
|
2584
2666
|
async lfsPreDownload(opts) {
|
|
@@ -2587,6 +2669,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2587
2669
|
}
|
|
2588
2670
|
const remote = opts?.remote ?? "origin";
|
|
2589
2671
|
const batchSize = opts?.batchSize ?? 50;
|
|
2672
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2673
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2674
|
+
}
|
|
2590
2675
|
let oids;
|
|
2591
2676
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2592
2677
|
oids = opts.oids;
|
|
@@ -6133,7 +6218,7 @@ var NodeExecAdapter = class {
|
|
|
6133
6218
|
const child = spawn(command, args, {
|
|
6134
6219
|
cwd,
|
|
6135
6220
|
env: resolveChildEnv(env, inheritEnv),
|
|
6136
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6221
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6137
6222
|
});
|
|
6138
6223
|
let stdout = "";
|
|
6139
6224
|
let stderr = "";
|
|
@@ -6161,6 +6246,12 @@ var NodeExecAdapter = class {
|
|
|
6161
6246
|
stderr += text;
|
|
6162
6247
|
handlers?.onStderr?.(text);
|
|
6163
6248
|
});
|
|
6249
|
+
child.stdin?.on("error", (error) => {
|
|
6250
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6251
|
+
reject(error);
|
|
6252
|
+
}
|
|
6253
|
+
});
|
|
6254
|
+
child.stdin?.end(options.stdin);
|
|
6164
6255
|
child.on("error", (error) => {
|
|
6165
6256
|
signal?.removeEventListener("abort", abortHandler);
|
|
6166
6257
|
reject(error);
|
|
@@ -6189,7 +6280,7 @@ var NodeExecAdapter = class {
|
|
|
6189
6280
|
const child = spawn(command, args, {
|
|
6190
6281
|
cwd,
|
|
6191
6282
|
env: resolveChildEnv(env, inheritEnv),
|
|
6192
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6283
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6193
6284
|
});
|
|
6194
6285
|
let aborted = false;
|
|
6195
6286
|
let exitSignal;
|
|
@@ -6214,6 +6305,12 @@ var NodeExecAdapter = class {
|
|
|
6214
6305
|
child.stderr?.on("data", (chunk) => {
|
|
6215
6306
|
stderr += chunk.toString("utf8");
|
|
6216
6307
|
});
|
|
6308
|
+
child.stdin?.on("error", (error) => {
|
|
6309
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6310
|
+
reject(error);
|
|
6311
|
+
}
|
|
6312
|
+
});
|
|
6313
|
+
child.stdin?.end(options.stdin);
|
|
6217
6314
|
child.on("error", (error) => {
|
|
6218
6315
|
signal?.removeEventListener("abort", abortHandler);
|
|
6219
6316
|
reject(error);
|