type-git 0.3.0-alpha.0 → 0.3.0-alpha.1

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/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 { k as AdapterFactory, A as AuditConfig, x as AuditEvent, w as AuditEventEnd, v as AuditEventStart, C as Capabilities, r as CommandSpec, t as Credential, u as CredentialConfig, s as CredentialRequest, E as ExecAdapter, e as ExecOpts, i as ExecutionContext, F as FsAdapter, p as GitArgumentError, j as GitError, G as GitErrorCategory, o as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, m as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, q as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, y as TraceEvent, l as isNonEmpty, n as nonEmpty } from './adapters-BEKkCViX.cjs';
2
+ export { l as AdapterFactory, A as AuditConfig, z as AuditEvent, y as AuditEventEnd, x as AuditEventStart, C as Capabilities, t as CommandSpec, v as Credential, w as CredentialConfig, u as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, i as EnvInheritance, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, q as GitArgumentError, k as GitError, G as GitErrorCategory, p as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, o as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, s as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, B as TraceEvent, m as isNonEmpty, n as nonEmpty, r as resolveInheritedEnv } from './adapters-Bpuvmw9y.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 { k as AdapterFactory, A as AuditConfig, x as AuditEvent, w as AuditEventEnd, v as AuditEventStart, C as Capabilities, r as CommandSpec, t as Credential, u as CredentialConfig, s as CredentialRequest, E as ExecAdapter, e as ExecOpts, i as ExecutionContext, F as FsAdapter, p as GitArgumentError, j as GitError, G as GitErrorCategory, o as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, m as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, q as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, y as TraceEvent, l as isNonEmpty, n as nonEmpty } from './adapters-BEKkCViX.js';
2
+ export { l as AdapterFactory, A as AuditConfig, z as AuditEvent, y as AuditEventEnd, x as AuditEventStart, C as Capabilities, t as CommandSpec, v as Credential, w as CredentialConfig, u as CredentialRequest, D as DEFAULT_ENV_ALLOWLIST, i as EnvInheritance, E as ExecAdapter, e as ExecOpts, j as ExecutionContext, F as FsAdapter, q as GitArgumentError, k as GitError, G as GitErrorCategory, p as GitErrorKind, h as GitOpenOptions, g as GitProgress, L as LfsMode, o as LfsProgress, N as NonEmptyString, O as OutputContract, f as RawResult, s as Runtime, R as RuntimeAdapters, c as SpawnHandle, S as SpawnOptions, b as SpawnResult, a as StreamHandler, d as TailHandle, T as TailOptions, B as TraceEvent, m as isNonEmpty, n as nonEmpty, r as resolveInheritedEnv } from './adapters-Bpuvmw9y.js';
package/dist/index.js CHANGED
@@ -502,6 +502,99 @@ function detectErrorCategory(stderr) {
502
502
 
503
503
  // src/runner/cli-runner.ts
504
504
  import process2 from "process";
505
+
506
+ // src/core/env.ts
507
+ var DEFAULT_ENV_ALLOWLIST = [
508
+ // Executable resolution
509
+ "PATH",
510
+ "PATHEXT",
511
+ // User home / identity
512
+ "HOME",
513
+ "USER",
514
+ "LOGNAME",
515
+ // Locale and time
516
+ "LANG",
517
+ "LANGUAGE",
518
+ "LC_ALL",
519
+ "LC_CTYPE",
520
+ "LC_MESSAGES",
521
+ "LC_NUMERIC",
522
+ "LC_TIME",
523
+ "LC_COLLATE",
524
+ "LC_MONETARY",
525
+ "TZ",
526
+ // Temporary directories
527
+ "TMPDIR",
528
+ "TMP",
529
+ "TEMP",
530
+ // Terminal
531
+ "TERM",
532
+ "COLORTERM",
533
+ // SSH agent (required for Git-over-SSH authentication)
534
+ "SSH_AUTH_SOCK",
535
+ "SSH_AGENT_PID",
536
+ // HTTP(S) proxy configuration (required for Git network operations behind a proxy)
537
+ "HTTP_PROXY",
538
+ "HTTPS_PROXY",
539
+ "http_proxy",
540
+ "https_proxy",
541
+ "ALL_PROXY",
542
+ "all_proxy",
543
+ "NO_PROXY",
544
+ "no_proxy",
545
+ // Windows essentials
546
+ "USERPROFILE",
547
+ "HOMEDRIVE",
548
+ "HOMEPATH",
549
+ "APPDATA",
550
+ "LOCALAPPDATA",
551
+ "PROGRAMDATA",
552
+ "ALLUSERSPROFILE",
553
+ "PROGRAMFILES",
554
+ "PROGRAMFILES(X86)",
555
+ "PROGRAMW6432",
556
+ "PUBLIC",
557
+ "SYSTEMROOT",
558
+ "SYSTEMDRIVE",
559
+ "WINDIR",
560
+ "COMSPEC",
561
+ "COMPUTERNAME",
562
+ "USERDOMAIN",
563
+ "NUMBER_OF_PROCESSORS",
564
+ "PROCESSOR_ARCHITECTURE"
565
+ ];
566
+ function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
567
+ if (inheritEnv === true) {
568
+ const all = {};
569
+ for (const [key, value] of Object.entries(parentEnv)) {
570
+ if (value !== void 0) {
571
+ all[key] = value;
572
+ }
573
+ }
574
+ return all;
575
+ }
576
+ const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
577
+ if (Array.isArray(inheritEnv)) {
578
+ for (const name of inheritEnv) {
579
+ allow.add(name);
580
+ }
581
+ }
582
+ const isWindows = platform === "win32";
583
+ const allowLower = isWindows ? new Set([...allow].map((name) => name.toLowerCase())) : null;
584
+ const result = {};
585
+ for (const [key, value] of Object.entries(parentEnv)) {
586
+ if (value === void 0) {
587
+ continue;
588
+ }
589
+ const allowed = allowLower ? allowLower.has(key.toLowerCase()) : allow.has(key);
590
+ if (allowed) {
591
+ result[key] = value;
592
+ }
593
+ }
594
+ return result;
595
+ }
596
+
597
+ // src/runner/cli-runner.ts
505
598
  var FATAL_ERROR_PATTERN = /fatal:\s*(.+)/i;
506
599
  var ERROR_PATTERN = /error:\s*(.+)/i;
507
600
  var LINE_SEPARATOR_PATTERN = /\r|\n/;
@@ -555,6 +648,7 @@ var CliRunner = class _CliRunner {
555
648
  exec;
556
649
  gitBinary;
557
650
  baseEnv;
651
+ inheritEnv;
558
652
  pathPrefix;
559
653
  home;
560
654
  credential;
@@ -563,6 +657,7 @@ var CliRunner = class _CliRunner {
563
657
  this.exec = adapters.exec;
564
658
  this.gitBinary = options?.gitBinary ?? "git";
565
659
  this.baseEnv = options?.env ?? {};
660
+ this.inheritEnv = options?.inheritEnv;
566
661
  this.pathPrefix = options?.pathPrefix ?? [];
567
662
  this.home = options?.home;
568
663
  this.credential = options?.credential;
@@ -576,6 +671,7 @@ var CliRunner = class _CliRunner {
576
671
  withOptions(options) {
577
672
  const mergedEnv = { ...this.baseEnv, ...options.env };
578
673
  const mergedPathPrefix = [...this.pathPrefix, ...options.pathPrefix ?? []];
674
+ const inheritEnv = options.inheritEnv ?? this.inheritEnv;
579
675
  const home = options.home ?? this.home;
580
676
  const credential = options.credential ?? this.credential;
581
677
  const audit = options.audit ?? this.audit;
@@ -593,6 +689,7 @@ var CliRunner = class _CliRunner {
593
689
  {
594
690
  gitBinary: options.gitBinary ?? this.gitBinary,
595
691
  env: mergedEnv,
692
+ inheritEnv,
596
693
  pathPrefix: mergedPathPrefix,
597
694
  home,
598
695
  credential,
@@ -624,10 +721,16 @@ var CliRunner = class _CliRunner {
624
721
  /**
625
722
  * Build the effective environment for command execution
626
723
  *
627
- * Applies home directory and PATH prefix overrides
724
+ * Seeds the environment from the inherited (allowlisted) parent variables, then layers
725
+ * the configured `env`, home directory, and PATH prefix overrides on top. The parent
726
+ * process environment is never forwarded wholesale unless `inheritEnv: true` is set
727
+ * (environment variable traversal prevention).
628
728
  */
629
729
  buildEnv() {
630
- const env = { ...this.baseEnv };
730
+ const env = {
731
+ ...resolveInheritedEnv(process2.env, this.inheritEnv, process2.platform),
732
+ ...this.baseEnv
733
+ };
631
734
  if (this.home) {
632
735
  env.HOME = this.home;
633
736
  env.USERPROFILE = this.home;
@@ -640,9 +743,11 @@ var CliRunner = class _CliRunner {
640
743
  }
641
744
  }
642
745
  if (allPathPrefixes.length > 0) {
643
- const separator = process2.platform === "win32" ? ";" : ":";
644
- const currentPath = process2.env.PATH ?? "";
645
- env.PATH = [...allPathPrefixes, currentPath].join(separator);
746
+ const isWindows = process2.platform === "win32";
747
+ const separator = isWindows ? ";" : ":";
748
+ const pathKey = isWindows ? Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "PATH" : "PATH";
749
+ const currentPath = env[pathKey] ?? "";
750
+ env[pathKey] = [...allPathPrefixes, currentPath].join(separator);
646
751
  }
647
752
  if (this.audit?.onTrace) {
648
753
  if (env.GIT_TRACE === void 0) {
@@ -693,6 +798,9 @@ var CliRunner = class _CliRunner {
693
798
  {
694
799
  argv,
695
800
  env,
801
+ // The env above is already fully resolved (including any inherited variables),
802
+ // so the adapter must not merge the parent environment on top of it.
803
+ inheritEnv: false,
696
804
  cwd: context.type === "worktree" ? context.workdir : void 0,
697
805
  signal
698
806
  },
@@ -5467,6 +5575,7 @@ function toCliRunnerOptions(opts) {
5467
5575
  }
5468
5576
  return {
5469
5577
  env: opts.env,
5578
+ inheritEnv: opts.inheritEnv,
5470
5579
  pathPrefix: opts.pathPrefix,
5471
5580
  home: opts.home,
5472
5581
  credential: opts.credential ? {
@@ -5910,6 +6019,12 @@ async function createGit(options) {
5910
6019
 
5911
6020
  // src/adapters/node/exec.ts
5912
6021
  import { spawn } from "child_process";
6022
+ function resolveChildEnv(env, inheritEnv) {
6023
+ if (inheritEnv === false) {
6024
+ return env ?? {};
6025
+ }
6026
+ return env ? { ...process.env, ...env } : process.env;
6027
+ }
5913
6028
  async function* streamToAsyncIterable(stream) {
5914
6029
  let buffer = "";
5915
6030
  for await (const chunk of stream) {
@@ -5936,7 +6051,7 @@ var NodeExecAdapter = class {
5936
6051
  };
5937
6052
  }
5938
6053
  spawn(options, handlers) {
5939
- const { argv, env, cwd, signal } = options;
6054
+ const { argv, env, inheritEnv, cwd, signal } = options;
5940
6055
  const command = argv[0];
5941
6056
  if (command === void 0) {
5942
6057
  throw new Error("argv must not be empty");
@@ -5945,7 +6060,7 @@ var NodeExecAdapter = class {
5945
6060
  return new Promise((resolve, reject) => {
5946
6061
  const child = spawn(command, args, {
5947
6062
  cwd,
5948
- env: env ? { ...process.env, ...env } : process.env,
6063
+ env: resolveChildEnv(env, inheritEnv),
5949
6064
  stdio: ["ignore", "pipe", "pipe"]
5950
6065
  });
5951
6066
  let stdout = "";
@@ -5993,7 +6108,7 @@ var NodeExecAdapter = class {
5993
6108
  });
5994
6109
  }
5995
6110
  spawnStreaming(options) {
5996
- const { argv, env, cwd, signal } = options;
6111
+ const { argv, env, inheritEnv, cwd, signal } = options;
5997
6112
  const command = argv[0];
5998
6113
  if (command === void 0) {
5999
6114
  throw new Error("argv must not be empty");
@@ -6001,7 +6116,7 @@ var NodeExecAdapter = class {
6001
6116
  const args = argv.slice(1);
6002
6117
  const child = spawn(command, args, {
6003
6118
  cwd,
6004
- env: env ? { ...process.env, ...env } : process.env,
6119
+ env: resolveChildEnv(env, inheritEnv),
6005
6120
  stdio: ["ignore", "pipe", "pipe"]
6006
6121
  });
6007
6122
  let aborted = false;
@@ -6398,6 +6513,7 @@ var TypeGit = class _TypeGit {
6398
6513
  };
6399
6514
  export {
6400
6515
  CliRunner,
6516
+ DEFAULT_ENV_ALLOWLIST,
6401
6517
  GIT_LOG_FORMAT,
6402
6518
  GitArgumentError,
6403
6519
  GitError,
@@ -6422,6 +6538,7 @@ export {
6422
6538
  parseLsTree,
6423
6539
  parsePorcelainV2,
6424
6540
  parseRecords,
6425
- parseWorktreeList
6541
+ parseWorktreeList,
6542
+ resolveInheritedEnv
6426
6543
  };
6427
6544
  //# sourceMappingURL=index.js.map