type-git 0.3.0-alpha.1 → 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 +230 -61
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +57 -6
- package/dist/adapters/node/index.d.ts +57 -6
- package/dist/adapters/node/index.js +230 -61
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-Bpuvmw9y.d.cts → adapters-CZ8wj9Kr.d.cts} +60 -8
- package/dist/{adapters-Bpuvmw9y.d.ts → adapters-CZ8wj9Kr.d.ts} +60 -8
- package/dist/index.cjs +230 -61
- 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 +230 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -596,6 +596,22 @@ var DEFAULT_ENV_ALLOWLIST = [
|
|
|
596
596
|
// SSH agent (required for Git-over-SSH authentication)
|
|
597
597
|
"SSH_AUTH_SOCK",
|
|
598
598
|
"SSH_AGENT_PID",
|
|
599
|
+
// Git SSH transport and TLS configuration. These are commonly required for
|
|
600
|
+
// fetch/push to keep working under the default allowlist. They are transport
|
|
601
|
+
// configuration rather than credential stores, but note they can still carry
|
|
602
|
+
// sensitive data depending on local setup (e.g. GIT_SSH_COMMAND can name a command
|
|
603
|
+
// Git executes). The most credential-prone / askpass variables (GIT_ASKPASS,
|
|
604
|
+
// SSH_ASKPASS, GIT_PROXY_COMMAND) are intentionally NOT inherited by default — they
|
|
605
|
+
// can carry inline credentials or run a helper that reads secrets from the
|
|
606
|
+
// environment, which would weaken the traversal-prevention model. Opt into those
|
|
607
|
+
// explicitly via `inheritEnv` when needed.
|
|
608
|
+
"GIT_SSH",
|
|
609
|
+
"GIT_SSH_COMMAND",
|
|
610
|
+
"GIT_SSH_VARIANT",
|
|
611
|
+
"GIT_SSL_CAINFO",
|
|
612
|
+
"GIT_SSL_CAPATH",
|
|
613
|
+
"GIT_TERMINAL_PROMPT",
|
|
614
|
+
"GIT_CONFIG_NOSYSTEM",
|
|
599
615
|
// HTTP(S) proxy configuration (required for Git network operations behind a proxy)
|
|
600
616
|
"HTTP_PROXY",
|
|
601
617
|
"HTTPS_PROXY",
|
|
@@ -626,35 +642,52 @@ var DEFAULT_ENV_ALLOWLIST = [
|
|
|
626
642
|
"NUMBER_OF_PROCESSORS",
|
|
627
643
|
"PROCESSOR_ARCHITECTURE"
|
|
628
644
|
];
|
|
629
|
-
function
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
all[key] = value;
|
|
635
|
-
}
|
|
645
|
+
function pickEnv(parentEnv, predicate) {
|
|
646
|
+
const result = {};
|
|
647
|
+
for (const [key, value] of Object.entries(parentEnv)) {
|
|
648
|
+
if (value !== void 0 && predicate(key)) {
|
|
649
|
+
result[key] = value;
|
|
636
650
|
}
|
|
637
|
-
return all;
|
|
638
651
|
}
|
|
652
|
+
return result;
|
|
653
|
+
}
|
|
654
|
+
function buildAllowlist(inheritEnv) {
|
|
639
655
|
const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
|
|
640
656
|
if (Array.isArray(inheritEnv)) {
|
|
641
657
|
for (const name of inheritEnv) {
|
|
642
658
|
allow.add(name);
|
|
643
659
|
}
|
|
660
|
+
return { allow, remove: void 0 };
|
|
644
661
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
const result = {};
|
|
648
|
-
for (const [key, value] of Object.entries(parentEnv)) {
|
|
649
|
-
if (value === void 0) {
|
|
650
|
-
continue;
|
|
651
|
-
}
|
|
652
|
-
const allowed = allowLower ? allowLower.has(key.toLowerCase()) : allow.has(key);
|
|
653
|
-
if (allowed) {
|
|
654
|
-
result[key] = value;
|
|
655
|
-
}
|
|
662
|
+
if (inheritEnv === false) {
|
|
663
|
+
return { allow, remove: void 0 };
|
|
656
664
|
}
|
|
657
|
-
|
|
665
|
+
for (const name of inheritEnv.add ?? []) {
|
|
666
|
+
allow.add(name);
|
|
667
|
+
}
|
|
668
|
+
const hasRemove = inheritEnv.remove !== void 0 && inheritEnv.remove.length > 0;
|
|
669
|
+
const remove = hasRemove ? new Set(inheritEnv.remove) : void 0;
|
|
670
|
+
return { allow, remove };
|
|
671
|
+
}
|
|
672
|
+
function makeNameMatcher(names, isWindows) {
|
|
673
|
+
if (!isWindows) {
|
|
674
|
+
return (name) => names.has(name);
|
|
675
|
+
}
|
|
676
|
+
const lower = new Set([...names].map((name) => name.toLowerCase()));
|
|
677
|
+
return (name) => lower.has(name.toLowerCase());
|
|
678
|
+
}
|
|
679
|
+
function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
|
|
680
|
+
if (inheritEnv === true) {
|
|
681
|
+
return pickEnv(parentEnv, () => true);
|
|
682
|
+
}
|
|
683
|
+
if (typeof inheritEnv === "function") {
|
|
684
|
+
return pickEnv(parentEnv, inheritEnv);
|
|
685
|
+
}
|
|
686
|
+
const { allow, remove } = buildAllowlist(inheritEnv ?? []);
|
|
687
|
+
const isWindows = platform === "win32";
|
|
688
|
+
const isAllowed = makeNameMatcher(allow, isWindows);
|
|
689
|
+
const isRemoved = remove ? makeNameMatcher(remove, isWindows) : () => false;
|
|
690
|
+
return pickEnv(parentEnv, (name) => isAllowed(name) && !isRemoved(name));
|
|
658
691
|
}
|
|
659
692
|
|
|
660
693
|
// src/runner/cli-runner.ts
|
|
@@ -839,8 +872,11 @@ var CliRunner = class _CliRunner {
|
|
|
839
872
|
*/
|
|
840
873
|
async run(context, args, opts) {
|
|
841
874
|
const argv = this.buildArgv(context, args);
|
|
842
|
-
const { signal, onProgress, onLfsProgress } = opts ?? {};
|
|
875
|
+
const { signal, onProgress, onLfsProgress, env: envOverride } = opts ?? {};
|
|
843
876
|
const env = this.buildEnv();
|
|
877
|
+
if (envOverride) {
|
|
878
|
+
Object.assign(env, envOverride);
|
|
879
|
+
}
|
|
844
880
|
if (onLfsProgress) {
|
|
845
881
|
env.GIT_LFS_FORCE_PROGRESS = "1";
|
|
846
882
|
}
|
|
@@ -860,6 +896,7 @@ var CliRunner = class _CliRunner {
|
|
|
860
896
|
result = await this.exec.spawn(
|
|
861
897
|
{
|
|
862
898
|
argv,
|
|
899
|
+
stdin: opts?.stdin,
|
|
863
900
|
env,
|
|
864
901
|
// The env above is already fully resolved (including any inherited variables),
|
|
865
902
|
// so the adapter must not merge the parent environment on top of it.
|
|
@@ -1408,7 +1445,7 @@ var BareRepoImpl = class {
|
|
|
1408
1445
|
*/
|
|
1409
1446
|
async push(opts) {
|
|
1410
1447
|
const args = ["push"];
|
|
1411
|
-
if (opts?.onProgress) {
|
|
1448
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
1412
1449
|
args.push("--progress");
|
|
1413
1450
|
}
|
|
1414
1451
|
if (opts?.force) {
|
|
@@ -1715,7 +1752,53 @@ var BareRepoImpl = class {
|
|
|
1715
1752
|
}
|
|
1716
1753
|
};
|
|
1717
1754
|
|
|
1755
|
+
// src/internal/concurrency.ts
|
|
1756
|
+
async function runWithConcurrency(items, run, options) {
|
|
1757
|
+
const { concurrency, warmupCount = 0 } = options;
|
|
1758
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
1759
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
1760
|
+
}
|
|
1761
|
+
if (!Number.isInteger(warmupCount) || warmupCount < 0) {
|
|
1762
|
+
throw new RangeError(`warmupCount must be a non-negative integer, got: ${warmupCount}`);
|
|
1763
|
+
}
|
|
1764
|
+
const results = new Array(items.length);
|
|
1765
|
+
let nextIndex = 0;
|
|
1766
|
+
let failed = false;
|
|
1767
|
+
let firstError;
|
|
1768
|
+
const runOne = async (index) => {
|
|
1769
|
+
try {
|
|
1770
|
+
const item = items[index];
|
|
1771
|
+
results[index] = await run(item, index);
|
|
1772
|
+
} catch (error) {
|
|
1773
|
+
if (!failed) {
|
|
1774
|
+
failed = true;
|
|
1775
|
+
firstError = error;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
};
|
|
1779
|
+
const warmupEnd = Math.min(warmupCount, items.length);
|
|
1780
|
+
while (nextIndex < warmupEnd && !failed) {
|
|
1781
|
+
await runOne(nextIndex++);
|
|
1782
|
+
}
|
|
1783
|
+
if (!failed && nextIndex < items.length) {
|
|
1784
|
+
const worker = async () => {
|
|
1785
|
+
while (!failed && nextIndex < items.length) {
|
|
1786
|
+
await runOne(nextIndex++);
|
|
1787
|
+
}
|
|
1788
|
+
};
|
|
1789
|
+
const workerCount = Math.min(concurrency, items.length - nextIndex);
|
|
1790
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
1791
|
+
}
|
|
1792
|
+
if (failed) {
|
|
1793
|
+
throw firstError;
|
|
1794
|
+
}
|
|
1795
|
+
return results;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1718
1798
|
// src/impl/worktree-repo-impl.ts
|
|
1799
|
+
var PRE_UPLOAD_DEFAULT_BATCH_SIZE = 200;
|
|
1800
|
+
var PRE_UPLOAD_DEFAULT_CONCURRENCY = 4;
|
|
1801
|
+
var PRE_UPLOAD_WARMUP_BATCH_COUNT = 1;
|
|
1719
1802
|
var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
1720
1803
|
workdir;
|
|
1721
1804
|
runner;
|
|
@@ -2306,7 +2389,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2306
2389
|
*/
|
|
2307
2390
|
async push(opts) {
|
|
2308
2391
|
const args = ["push"];
|
|
2309
|
-
if (opts?.onProgress) {
|
|
2392
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2310
2393
|
args.push("--progress");
|
|
2311
2394
|
}
|
|
2312
2395
|
if (opts?.verbose) {
|
|
@@ -2411,6 +2494,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2411
2494
|
setLfsMode(mode) {
|
|
2412
2495
|
this._lfsMode = mode;
|
|
2413
2496
|
}
|
|
2497
|
+
/**
|
|
2498
|
+
* Per-command environment overrides derived from the configured LFS mode.
|
|
2499
|
+
*
|
|
2500
|
+
* When the repository was opened (or reconfigured) with an object-form LFS
|
|
2501
|
+
* mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
|
|
2502
|
+
* operations (checkout, switch, reset, merge, pull, rebase, restore) run with
|
|
2503
|
+
* `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
|
|
2504
|
+
* of downloading their contents during the implicit checkout.
|
|
2505
|
+
*
|
|
2506
|
+
* The objects can be materialized later via the explicit `repo.lfs.pull()` /
|
|
2507
|
+
* `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
|
|
2508
|
+
* not affected by `GIT_LFS_SKIP_SMUDGE`.
|
|
2509
|
+
*
|
|
2510
|
+
* Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
|
|
2511
|
+
* runner environment is left untouched.
|
|
2512
|
+
*/
|
|
2513
|
+
lfsModeEnv() {
|
|
2514
|
+
const mode = this._lfsMode;
|
|
2515
|
+
if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
|
|
2516
|
+
return { GIT_LFS_SKIP_SMUDGE: "1" };
|
|
2517
|
+
}
|
|
2518
|
+
return void 0;
|
|
2519
|
+
}
|
|
2414
2520
|
// ==========================================================================
|
|
2415
2521
|
// LFS Operations
|
|
2416
2522
|
// ==========================================================================
|
|
@@ -2433,36 +2539,41 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2433
2539
|
}
|
|
2434
2540
|
await this.runner.runOrThrow(this.context, args, {
|
|
2435
2541
|
signal: opts?.signal,
|
|
2436
|
-
onProgress: opts?.onProgress
|
|
2542
|
+
onProgress: opts?.onProgress,
|
|
2543
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2437
2544
|
});
|
|
2438
2545
|
}
|
|
2439
2546
|
async lfsPush(opts) {
|
|
2440
2547
|
if (this._lfsMode === "disabled") {
|
|
2441
2548
|
return;
|
|
2442
2549
|
}
|
|
2550
|
+
if (opts?.stdin && opts.objectId === void 0 && !opts.ref) {
|
|
2551
|
+
throw new TypeError("lfs.push with stdin requires objectId or ref");
|
|
2552
|
+
}
|
|
2443
2553
|
const args = ["lfs", "push"];
|
|
2444
2554
|
if (opts?.dryRun) {
|
|
2445
2555
|
args.push("--dry-run");
|
|
2446
2556
|
}
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
} else {
|
|
2453
|
-
args.push("--all");
|
|
2557
|
+
const oids = opts?.objectId !== void 0 ? Array.isArray(opts.objectId) ? opts.objectId : [opts.objectId] : void 0;
|
|
2558
|
+
if (oids?.length === 0 && !opts?.stdin) {
|
|
2559
|
+
throw new TypeError(
|
|
2560
|
+
"lfs.push with objectId requires at least one OID unless stdin is enabled"
|
|
2561
|
+
);
|
|
2454
2562
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2563
|
+
args.push(oids ? "--object-id" : "--all");
|
|
2564
|
+
args.push(opts?.remote ?? "origin");
|
|
2565
|
+
const values = oids ?? (opts?.ref ? [opts.ref] : []);
|
|
2566
|
+
if (opts?.stdin) {
|
|
2567
|
+
args.push("--stdin");
|
|
2457
2568
|
} else {
|
|
2458
|
-
args.push(
|
|
2459
|
-
}
|
|
2460
|
-
if (opts?.ref) {
|
|
2461
|
-
args.push(opts.ref);
|
|
2569
|
+
args.push(...values);
|
|
2462
2570
|
}
|
|
2463
2571
|
await this.runner.runOrThrow(this.context, args, {
|
|
2572
|
+
stdin: opts?.stdin ? values.length > 0 ? `${values.join("\n")}
|
|
2573
|
+
` : "" : void 0,
|
|
2464
2574
|
signal: opts?.signal,
|
|
2465
|
-
onProgress: opts?.onProgress
|
|
2575
|
+
onProgress: opts?.onProgress,
|
|
2576
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2466
2577
|
});
|
|
2467
2578
|
}
|
|
2468
2579
|
async lfsStatus(opts) {
|
|
@@ -2498,12 +2609,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2498
2609
|
* Pre-upload LFS objects before commit/push (2-phase commit pattern)
|
|
2499
2610
|
*
|
|
2500
2611
|
* This allows uploading LFS objects to the remote before creating a commit,
|
|
2501
|
-
* ensuring reliable large file handling. Objects are batched to
|
|
2502
|
-
*
|
|
2612
|
+
* ensuring reliable large file handling. Objects are batched to stay within
|
|
2613
|
+
* command-line length limits, and batches run with bounded concurrency to
|
|
2614
|
+
* overlap per-invocation fixed costs with other batches' transfers.
|
|
2615
|
+
*
|
|
2616
|
+
* Failure handling: once a batch fails, no new batch is started (in-flight
|
|
2617
|
+
* batches are awaited), and the objects of failed and unstarted batches are
|
|
2618
|
+
* reported in `skippedCount`. The first batch always runs alone before the
|
|
2619
|
+
* remaining batches widen to the concurrency limit, so a failure common to
|
|
2620
|
+
* all batches costs a single round-trip.
|
|
2503
2621
|
*
|
|
2504
2622
|
* Usage pattern:
|
|
2505
2623
|
* 1. Stage changes: git add
|
|
2506
|
-
* 2. Pre-upload LFS: await repo.
|
|
2624
|
+
* 2. Pre-upload LFS: await repo.lfsExtra.preUpload()
|
|
2507
2625
|
* 3. Commit: git commit
|
|
2508
2626
|
* 4. Push refs: git push (only refs, objects already uploaded)
|
|
2509
2627
|
*/
|
|
@@ -2512,7 +2630,14 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2512
2630
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2513
2631
|
}
|
|
2514
2632
|
const remote = opts?.remote ?? "origin";
|
|
2515
|
-
const batchSize = opts?.batchSize ??
|
|
2633
|
+
const batchSize = opts?.batchSize ?? PRE_UPLOAD_DEFAULT_BATCH_SIZE;
|
|
2634
|
+
const concurrency = opts?.concurrency ?? PRE_UPLOAD_DEFAULT_CONCURRENCY;
|
|
2635
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2636
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2637
|
+
}
|
|
2638
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
2639
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
2640
|
+
}
|
|
2516
2641
|
let oids;
|
|
2517
2642
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2518
2643
|
oids = opts.oids;
|
|
@@ -2537,17 +2662,24 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2537
2662
|
if (oids.length === 0) {
|
|
2538
2663
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2539
2664
|
}
|
|
2665
|
+
const batches = [];
|
|
2666
|
+
for (let i = 0; i < oids.length; i += batchSize) {
|
|
2667
|
+
batches.push(oids.slice(i, i + batchSize));
|
|
2668
|
+
}
|
|
2540
2669
|
let uploadedCount = 0;
|
|
2541
2670
|
let uploadedBytes = 0;
|
|
2542
2671
|
let skippedCount = 0;
|
|
2543
|
-
|
|
2544
|
-
|
|
2672
|
+
let attemptedCount = 0;
|
|
2673
|
+
const batchFailedStop = new Error("lfs pre-upload batch failed");
|
|
2674
|
+
const pushBatch = async (batch) => {
|
|
2545
2675
|
const args = ["lfs", "push", remote, "--object-id", ...batch];
|
|
2546
2676
|
const result = await this.runner.run(this.context, args, {
|
|
2547
2677
|
signal: opts?.signal,
|
|
2548
|
-
onProgress: opts?.onProgress
|
|
2678
|
+
onProgress: opts?.onProgress,
|
|
2679
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2549
2680
|
});
|
|
2550
|
-
|
|
2681
|
+
attemptedCount += batch.length;
|
|
2682
|
+
if (result.exitCode === 0 && !result.aborted) {
|
|
2551
2683
|
uploadedCount += batch.length;
|
|
2552
2684
|
const bytesMatch = result.stderr.match(
|
|
2553
2685
|
/Uploading LFS objects:.*?\((\d+(?:\.\d+)?)\s*([KMG]?B)/i
|
|
@@ -2567,7 +2699,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2567
2699
|
}
|
|
2568
2700
|
} else {
|
|
2569
2701
|
skippedCount += batch.length;
|
|
2702
|
+
throw batchFailedStop;
|
|
2570
2703
|
}
|
|
2704
|
+
};
|
|
2705
|
+
try {
|
|
2706
|
+
await runWithConcurrency(batches, pushBatch, {
|
|
2707
|
+
concurrency,
|
|
2708
|
+
warmupCount: PRE_UPLOAD_WARMUP_BATCH_COUNT
|
|
2709
|
+
});
|
|
2710
|
+
} catch (error) {
|
|
2711
|
+
if (error !== batchFailedStop) {
|
|
2712
|
+
throw error;
|
|
2713
|
+
}
|
|
2714
|
+
skippedCount += oids.length - attemptedCount;
|
|
2571
2715
|
}
|
|
2572
2716
|
return { uploadedCount, uploadedBytes, skippedCount };
|
|
2573
2717
|
}
|
|
@@ -2579,7 +2723,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2579
2723
|
*
|
|
2580
2724
|
* Usage pattern:
|
|
2581
2725
|
* 1. Fetch refs: git fetch
|
|
2582
|
-
* 2. Pre-download LFS: await repo.
|
|
2726
|
+
* 2. Pre-download LFS: await repo.lfsExtra.preDownload({ ref: 'origin/feature' })
|
|
2583
2727
|
* 3. Checkout: git checkout feature
|
|
2584
2728
|
*/
|
|
2585
2729
|
async lfsPreDownload(opts) {
|
|
@@ -2588,6 +2732,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2588
2732
|
}
|
|
2589
2733
|
const remote = opts?.remote ?? "origin";
|
|
2590
2734
|
const batchSize = opts?.batchSize ?? 50;
|
|
2735
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2736
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2737
|
+
}
|
|
2591
2738
|
let oids;
|
|
2592
2739
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2593
2740
|
oids = opts.oids;
|
|
@@ -2622,7 +2769,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2622
2769
|
const args = ["lfs", "fetch", remote, "--", ...batch];
|
|
2623
2770
|
const result = await this.runner.run(this.context, args, {
|
|
2624
2771
|
signal: opts?.signal,
|
|
2625
|
-
onProgress: opts?.onProgress
|
|
2772
|
+
onProgress: opts?.onProgress,
|
|
2773
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2626
2774
|
});
|
|
2627
2775
|
if (result.exitCode === 0) {
|
|
2628
2776
|
downloadedCount += batch.length;
|
|
@@ -2687,7 +2835,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2687
2835
|
return;
|
|
2688
2836
|
}
|
|
2689
2837
|
const args = ["lfs", "fetch"];
|
|
2690
|
-
if (opts?.onProgress) {
|
|
2838
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2691
2839
|
args.push("--progress");
|
|
2692
2840
|
}
|
|
2693
2841
|
if (opts?.all) {
|
|
@@ -2720,7 +2868,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2720
2868
|
}
|
|
2721
2869
|
await this.runner.runOrThrow(this.context, args, {
|
|
2722
2870
|
signal: opts?.signal,
|
|
2723
|
-
onProgress: opts?.onProgress
|
|
2871
|
+
onProgress: opts?.onProgress,
|
|
2872
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2724
2873
|
});
|
|
2725
2874
|
}
|
|
2726
2875
|
async lfsInstall(opts) {
|
|
@@ -3482,7 +3631,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3482
3631
|
}
|
|
3483
3632
|
}
|
|
3484
3633
|
await this.runner.runOrThrow(this.context, args, {
|
|
3485
|
-
signal: opts?.signal
|
|
3634
|
+
signal: opts?.signal,
|
|
3635
|
+
env: this.lfsModeEnv()
|
|
3486
3636
|
});
|
|
3487
3637
|
}
|
|
3488
3638
|
// ==========================================================================
|
|
@@ -3839,7 +3989,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3839
3989
|
}
|
|
3840
3990
|
args.push(branch);
|
|
3841
3991
|
const result = await this.runner.run(this.context, args, {
|
|
3842
|
-
signal: opts?.signal
|
|
3992
|
+
signal: opts?.signal,
|
|
3993
|
+
env: this.lfsModeEnv()
|
|
3843
3994
|
});
|
|
3844
3995
|
if (result.exitCode !== 0) {
|
|
3845
3996
|
const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
|
|
@@ -3868,7 +4019,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3868
4019
|
// ==========================================================================
|
|
3869
4020
|
async pull(opts) {
|
|
3870
4021
|
const args = ["pull"];
|
|
3871
|
-
if (opts?.onProgress) {
|
|
4022
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
3872
4023
|
args.push("--progress");
|
|
3873
4024
|
}
|
|
3874
4025
|
if (opts?.rebase === true) {
|
|
@@ -4016,7 +4167,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4016
4167
|
}
|
|
4017
4168
|
await this.runner.runOrThrow(this.context, args, {
|
|
4018
4169
|
signal: opts?.signal,
|
|
4019
|
-
onProgress: opts?.onProgress
|
|
4170
|
+
onProgress: opts?.onProgress,
|
|
4171
|
+
onLfsProgress: opts?.onLfsProgress,
|
|
4172
|
+
env: this.lfsModeEnv()
|
|
4020
4173
|
});
|
|
4021
4174
|
}
|
|
4022
4175
|
// ==========================================================================
|
|
@@ -4046,7 +4199,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4046
4199
|
args.push(target);
|
|
4047
4200
|
}
|
|
4048
4201
|
await this.runner.runOrThrow(this.context, args, {
|
|
4049
|
-
signal: opts?.signal
|
|
4202
|
+
signal: opts?.signal,
|
|
4203
|
+
env: this.lfsModeEnv()
|
|
4050
4204
|
});
|
|
4051
4205
|
}
|
|
4052
4206
|
// ==========================================================================
|
|
@@ -4242,7 +4396,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4242
4396
|
args.push(opts.startPoint);
|
|
4243
4397
|
}
|
|
4244
4398
|
await this.runner.runOrThrow(this.context, args, {
|
|
4245
|
-
signal: opts?.signal
|
|
4399
|
+
signal: opts?.signal,
|
|
4400
|
+
env: this.lfsModeEnv()
|
|
4246
4401
|
});
|
|
4247
4402
|
}
|
|
4248
4403
|
// ==========================================================================
|
|
@@ -4669,7 +4824,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4669
4824
|
args.push(opts.upstream);
|
|
4670
4825
|
}
|
|
4671
4826
|
await this.runner.runOrThrow(this.context, args, {
|
|
4672
|
-
signal: opts?.signal
|
|
4827
|
+
signal: opts?.signal,
|
|
4828
|
+
env: this.lfsModeEnv()
|
|
4673
4829
|
});
|
|
4674
4830
|
}
|
|
4675
4831
|
// ==========================================================================
|
|
@@ -4727,7 +4883,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4727
4883
|
const pathList = Array.isArray(paths) ? paths : [paths];
|
|
4728
4884
|
args.push("--", ...pathList);
|
|
4729
4885
|
await this.runner.runOrThrow(this.context, args, {
|
|
4730
|
-
signal: opts?.signal
|
|
4886
|
+
signal: opts?.signal,
|
|
4887
|
+
env: this.lfsModeEnv()
|
|
4731
4888
|
});
|
|
4732
4889
|
}
|
|
4733
4890
|
// ==========================================================================
|
|
@@ -5740,7 +5897,7 @@ var GitImpl = class {
|
|
|
5740
5897
|
}
|
|
5741
5898
|
async clone(url, path, opts) {
|
|
5742
5899
|
const args = buildCloneArgs(opts);
|
|
5743
|
-
if (opts?.onProgress) {
|
|
5900
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
5744
5901
|
args.push("--progress");
|
|
5745
5902
|
}
|
|
5746
5903
|
args.push(url, path);
|
|
@@ -6124,7 +6281,7 @@ var NodeExecAdapter = class {
|
|
|
6124
6281
|
const child = (0, import_node_child_process.spawn)(command, args, {
|
|
6125
6282
|
cwd,
|
|
6126
6283
|
env: resolveChildEnv(env, inheritEnv),
|
|
6127
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6284
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6128
6285
|
});
|
|
6129
6286
|
let stdout = "";
|
|
6130
6287
|
let stderr = "";
|
|
@@ -6152,6 +6309,12 @@ var NodeExecAdapter = class {
|
|
|
6152
6309
|
stderr += text;
|
|
6153
6310
|
handlers?.onStderr?.(text);
|
|
6154
6311
|
});
|
|
6312
|
+
child.stdin?.on("error", (error) => {
|
|
6313
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6314
|
+
reject(error);
|
|
6315
|
+
}
|
|
6316
|
+
});
|
|
6317
|
+
child.stdin?.end(options.stdin);
|
|
6155
6318
|
child.on("error", (error) => {
|
|
6156
6319
|
signal?.removeEventListener("abort", abortHandler);
|
|
6157
6320
|
reject(error);
|
|
@@ -6180,7 +6343,7 @@ var NodeExecAdapter = class {
|
|
|
6180
6343
|
const child = (0, import_node_child_process.spawn)(command, args, {
|
|
6181
6344
|
cwd,
|
|
6182
6345
|
env: resolveChildEnv(env, inheritEnv),
|
|
6183
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6346
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6184
6347
|
});
|
|
6185
6348
|
let aborted = false;
|
|
6186
6349
|
let exitSignal;
|
|
@@ -6205,6 +6368,12 @@ var NodeExecAdapter = class {
|
|
|
6205
6368
|
child.stderr?.on("data", (chunk) => {
|
|
6206
6369
|
stderr += chunk.toString("utf8");
|
|
6207
6370
|
});
|
|
6371
|
+
child.stdin?.on("error", (error) => {
|
|
6372
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6373
|
+
reject(error);
|
|
6374
|
+
}
|
|
6375
|
+
});
|
|
6376
|
+
child.stdin?.end(options.stdin);
|
|
6208
6377
|
child.on("error", (error) => {
|
|
6209
6378
|
signal?.removeEventListener("abort", abortHandler);
|
|
6210
6379
|
reject(error);
|