type-git 0.3.0-alpha.1 → 0.3.0-alpha.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.
@@ -1,4 +1,4 @@
1
- import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-Bpuvmw9y.cjs';
1
+ import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-sSzx9O1u.cjs';
2
2
 
3
3
  /**
4
4
  * Bun ExecAdapter implementation
@@ -1,4 +1,4 @@
1
- import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-Bpuvmw9y.js';
1
+ import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-sSzx9O1u.js';
2
2
 
3
3
  /**
4
4
  * Bun ExecAdapter implementation
@@ -1,4 +1,4 @@
1
- import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-Bpuvmw9y.cjs';
1
+ import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-sSzx9O1u.cjs';
2
2
 
3
3
  /**
4
4
  * Deno ExecAdapter implementation
@@ -1,4 +1,4 @@
1
- import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-Bpuvmw9y.js';
1
+ import { E as ExecAdapter, C as Capabilities, S as SpawnOptions, a as StreamHandler, b as SpawnResult, c as SpawnHandle, F as FsAdapter, T as TailOptions, d as TailHandle, R as RuntimeAdapters } from '../../adapters-sSzx9O1u.js';
2
2
 
3
3
  /**
4
4
  * Deno ExecAdapter implementation
@@ -487,6 +487,22 @@ var DEFAULT_ENV_ALLOWLIST = [
487
487
  // SSH agent (required for Git-over-SSH authentication)
488
488
  "SSH_AUTH_SOCK",
489
489
  "SSH_AGENT_PID",
490
+ // Git SSH transport and TLS configuration. These are commonly required for
491
+ // fetch/push to keep working under the default allowlist. They are transport
492
+ // configuration rather than credential stores, but note they can still carry
493
+ // sensitive data depending on local setup (e.g. GIT_SSH_COMMAND can name a command
494
+ // Git executes). The most credential-prone / askpass variables (GIT_ASKPASS,
495
+ // SSH_ASKPASS, GIT_PROXY_COMMAND) are intentionally NOT inherited by default — they
496
+ // can carry inline credentials or run a helper that reads secrets from the
497
+ // environment, which would weaken the traversal-prevention model. Opt into those
498
+ // explicitly via `inheritEnv` when needed.
499
+ "GIT_SSH",
500
+ "GIT_SSH_COMMAND",
501
+ "GIT_SSH_VARIANT",
502
+ "GIT_SSL_CAINFO",
503
+ "GIT_SSL_CAPATH",
504
+ "GIT_TERMINAL_PROMPT",
505
+ "GIT_CONFIG_NOSYSTEM",
490
506
  // HTTP(S) proxy configuration (required for Git network operations behind a proxy)
491
507
  "HTTP_PROXY",
492
508
  "HTTPS_PROXY",
@@ -517,35 +533,52 @@ var DEFAULT_ENV_ALLOWLIST = [
517
533
  "NUMBER_OF_PROCESSORS",
518
534
  "PROCESSOR_ARCHITECTURE"
519
535
  ];
520
- function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
521
- if (inheritEnv === true) {
522
- const all = {};
523
- for (const [key, value] of Object.entries(parentEnv)) {
524
- if (value !== void 0) {
525
- all[key] = value;
526
- }
536
+ function pickEnv(parentEnv, predicate) {
537
+ const result = {};
538
+ for (const [key, value] of Object.entries(parentEnv)) {
539
+ if (value !== void 0 && predicate(key)) {
540
+ result[key] = value;
527
541
  }
528
- return all;
529
542
  }
543
+ return result;
544
+ }
545
+ function buildAllowlist(inheritEnv) {
530
546
  const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
531
547
  if (Array.isArray(inheritEnv)) {
532
548
  for (const name of inheritEnv) {
533
549
  allow.add(name);
534
550
  }
551
+ return { allow, remove: void 0 };
535
552
  }
536
- const isWindows = platform === "win32";
537
- const allowLower = isWindows ? new Set([...allow].map((name) => name.toLowerCase())) : null;
538
- const result = {};
539
- for (const [key, value] of Object.entries(parentEnv)) {
540
- if (value === void 0) {
541
- continue;
542
- }
543
- const allowed = allowLower ? allowLower.has(key.toLowerCase()) : allow.has(key);
544
- if (allowed) {
545
- result[key] = value;
546
- }
553
+ if (inheritEnv === false) {
554
+ return { allow, remove: void 0 };
547
555
  }
548
- return result;
556
+ for (const name of inheritEnv.add ?? []) {
557
+ allow.add(name);
558
+ }
559
+ const hasRemove = inheritEnv.remove !== void 0 && inheritEnv.remove.length > 0;
560
+ const remove = hasRemove ? new Set(inheritEnv.remove) : void 0;
561
+ return { allow, remove };
562
+ }
563
+ function makeNameMatcher(names, isWindows) {
564
+ if (!isWindows) {
565
+ return (name) => names.has(name);
566
+ }
567
+ const lower = new Set([...names].map((name) => name.toLowerCase()));
568
+ return (name) => lower.has(name.toLowerCase());
569
+ }
570
+ function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
571
+ if (inheritEnv === true) {
572
+ return pickEnv(parentEnv, () => true);
573
+ }
574
+ if (typeof inheritEnv === "function") {
575
+ return pickEnv(parentEnv, inheritEnv);
576
+ }
577
+ const { allow, remove } = buildAllowlist(inheritEnv ?? []);
578
+ const isWindows = platform === "win32";
579
+ const isAllowed = makeNameMatcher(allow, isWindows);
580
+ const isRemoved = remove ? makeNameMatcher(remove, isWindows) : () => false;
581
+ return pickEnv(parentEnv, (name) => isAllowed(name) && !isRemoved(name));
549
582
  }
550
583
 
551
584
  // src/runner/cli-runner.ts
@@ -730,8 +763,11 @@ var CliRunner = class _CliRunner {
730
763
  */
731
764
  async run(context, args, opts) {
732
765
  const argv = this.buildArgv(context, args);
733
- const { signal, onProgress, onLfsProgress } = opts ?? {};
766
+ const { signal, onProgress, onLfsProgress, env: envOverride } = opts ?? {};
734
767
  const env = this.buildEnv();
768
+ if (envOverride) {
769
+ Object.assign(env, envOverride);
770
+ }
735
771
  if (onLfsProgress) {
736
772
  env.GIT_LFS_FORCE_PROGRESS = "1";
737
773
  }
@@ -1299,7 +1335,7 @@ var BareRepoImpl = class {
1299
1335
  */
1300
1336
  async push(opts) {
1301
1337
  const args = ["push"];
1302
- if (opts?.onProgress) {
1338
+ if (opts?.onProgress || opts?.onLfsProgress) {
1303
1339
  args.push("--progress");
1304
1340
  }
1305
1341
  if (opts?.force) {
@@ -2197,7 +2233,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2197
2233
  */
2198
2234
  async push(opts) {
2199
2235
  const args = ["push"];
2200
- if (opts?.onProgress) {
2236
+ if (opts?.onProgress || opts?.onLfsProgress) {
2201
2237
  args.push("--progress");
2202
2238
  }
2203
2239
  if (opts?.verbose) {
@@ -2302,6 +2338,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2302
2338
  setLfsMode(mode) {
2303
2339
  this._lfsMode = mode;
2304
2340
  }
2341
+ /**
2342
+ * Per-command environment overrides derived from the configured LFS mode.
2343
+ *
2344
+ * When the repository was opened (or reconfigured) with an object-form LFS
2345
+ * mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
2346
+ * operations (checkout, switch, reset, merge, pull, rebase, restore) run with
2347
+ * `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
2348
+ * of downloading their contents during the implicit checkout.
2349
+ *
2350
+ * The objects can be materialized later via the explicit `repo.lfs.pull()` /
2351
+ * `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
2352
+ * not affected by `GIT_LFS_SKIP_SMUDGE`.
2353
+ *
2354
+ * Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
2355
+ * runner environment is left untouched.
2356
+ */
2357
+ lfsModeEnv() {
2358
+ const mode = this._lfsMode;
2359
+ if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
2360
+ return { GIT_LFS_SKIP_SMUDGE: "1" };
2361
+ }
2362
+ return void 0;
2363
+ }
2305
2364
  // ==========================================================================
2306
2365
  // LFS Operations
2307
2366
  // ==========================================================================
@@ -2324,7 +2383,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2324
2383
  }
2325
2384
  await this.runner.runOrThrow(this.context, args, {
2326
2385
  signal: opts?.signal,
2327
- onProgress: opts?.onProgress
2386
+ onProgress: opts?.onProgress,
2387
+ onLfsProgress: opts?.onLfsProgress
2328
2388
  });
2329
2389
  }
2330
2390
  async lfsPush(opts) {
@@ -2353,7 +2413,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2353
2413
  }
2354
2414
  await this.runner.runOrThrow(this.context, args, {
2355
2415
  signal: opts?.signal,
2356
- onProgress: opts?.onProgress
2416
+ onProgress: opts?.onProgress,
2417
+ onLfsProgress: opts?.onLfsProgress
2357
2418
  });
2358
2419
  }
2359
2420
  async lfsStatus(opts) {
@@ -2436,7 +2497,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2436
2497
  const args = ["lfs", "push", remote, "--object-id", ...batch];
2437
2498
  const result = await this.runner.run(this.context, args, {
2438
2499
  signal: opts?.signal,
2439
- onProgress: opts?.onProgress
2500
+ onProgress: opts?.onProgress,
2501
+ onLfsProgress: opts?.onLfsProgress
2440
2502
  });
2441
2503
  if (result.exitCode === 0) {
2442
2504
  uploadedCount += batch.length;
@@ -2513,7 +2575,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2513
2575
  const args = ["lfs", "fetch", remote, "--", ...batch];
2514
2576
  const result = await this.runner.run(this.context, args, {
2515
2577
  signal: opts?.signal,
2516
- onProgress: opts?.onProgress
2578
+ onProgress: opts?.onProgress,
2579
+ onLfsProgress: opts?.onLfsProgress
2517
2580
  });
2518
2581
  if (result.exitCode === 0) {
2519
2582
  downloadedCount += batch.length;
@@ -2578,7 +2641,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2578
2641
  return;
2579
2642
  }
2580
2643
  const args = ["lfs", "fetch"];
2581
- if (opts?.onProgress) {
2644
+ if (opts?.onProgress || opts?.onLfsProgress) {
2582
2645
  args.push("--progress");
2583
2646
  }
2584
2647
  if (opts?.all) {
@@ -2611,7 +2674,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
2611
2674
  }
2612
2675
  await this.runner.runOrThrow(this.context, args, {
2613
2676
  signal: opts?.signal,
2614
- onProgress: opts?.onProgress
2677
+ onProgress: opts?.onProgress,
2678
+ onLfsProgress: opts?.onLfsProgress
2615
2679
  });
2616
2680
  }
2617
2681
  async lfsInstall(opts) {
@@ -3373,7 +3437,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3373
3437
  }
3374
3438
  }
3375
3439
  await this.runner.runOrThrow(this.context, args, {
3376
- signal: opts?.signal
3440
+ signal: opts?.signal,
3441
+ env: this.lfsModeEnv()
3377
3442
  });
3378
3443
  }
3379
3444
  // ==========================================================================
@@ -3730,7 +3795,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3730
3795
  }
3731
3796
  args.push(branch);
3732
3797
  const result = await this.runner.run(this.context, args, {
3733
- signal: opts?.signal
3798
+ signal: opts?.signal,
3799
+ env: this.lfsModeEnv()
3734
3800
  });
3735
3801
  if (result.exitCode !== 0) {
3736
3802
  const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
@@ -3759,7 +3825,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3759
3825
  // ==========================================================================
3760
3826
  async pull(opts) {
3761
3827
  const args = ["pull"];
3762
- if (opts?.onProgress) {
3828
+ if (opts?.onProgress || opts?.onLfsProgress) {
3763
3829
  args.push("--progress");
3764
3830
  }
3765
3831
  if (opts?.rebase === true) {
@@ -3907,7 +3973,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3907
3973
  }
3908
3974
  await this.runner.runOrThrow(this.context, args, {
3909
3975
  signal: opts?.signal,
3910
- onProgress: opts?.onProgress
3976
+ onProgress: opts?.onProgress,
3977
+ onLfsProgress: opts?.onLfsProgress,
3978
+ env: this.lfsModeEnv()
3911
3979
  });
3912
3980
  }
3913
3981
  // ==========================================================================
@@ -3937,7 +4005,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
3937
4005
  args.push(target);
3938
4006
  }
3939
4007
  await this.runner.runOrThrow(this.context, args, {
3940
- signal: opts?.signal
4008
+ signal: opts?.signal,
4009
+ env: this.lfsModeEnv()
3941
4010
  });
3942
4011
  }
3943
4012
  // ==========================================================================
@@ -4133,7 +4202,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4133
4202
  args.push(opts.startPoint);
4134
4203
  }
4135
4204
  await this.runner.runOrThrow(this.context, args, {
4136
- signal: opts?.signal
4205
+ signal: opts?.signal,
4206
+ env: this.lfsModeEnv()
4137
4207
  });
4138
4208
  }
4139
4209
  // ==========================================================================
@@ -4560,7 +4630,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4560
4630
  args.push(opts.upstream);
4561
4631
  }
4562
4632
  await this.runner.runOrThrow(this.context, args, {
4563
- signal: opts?.signal
4633
+ signal: opts?.signal,
4634
+ env: this.lfsModeEnv()
4564
4635
  });
4565
4636
  }
4566
4637
  // ==========================================================================
@@ -4618,7 +4689,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
4618
4689
  const pathList = Array.isArray(paths) ? paths : [paths];
4619
4690
  args.push("--", ...pathList);
4620
4691
  await this.runner.runOrThrow(this.context, args, {
4621
- signal: opts?.signal
4692
+ signal: opts?.signal,
4693
+ env: this.lfsModeEnv()
4622
4694
  });
4623
4695
  }
4624
4696
  // ==========================================================================
@@ -5631,7 +5703,7 @@ var GitImpl = class {
5631
5703
  }
5632
5704
  async clone(url, path, opts) {
5633
5705
  const args = buildCloneArgs(opts);
5634
- if (opts?.onProgress) {
5706
+ if (opts?.onProgress || opts?.onLfsProgress) {
5635
5707
  args.push("--progress");
5636
5708
  }
5637
5709
  args.push(url, path);