type-git 0.3.0-alpha.0 → 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.
- package/dist/adapters/bun/index.cjs +10 -4
- 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 +10 -4
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +10 -4
- 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 +10 -4
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +214 -27
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +35 -4
- package/dist/adapters/node/index.d.ts +35 -4
- package/dist/adapters/node/index.js +214 -27
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-BEKkCViX.d.cts → adapters-sSzx9O1u.d.cts} +121 -4
- package/dist/{adapters-BEKkCViX.d.ts → adapters-sSzx9O1u.d.ts} +121 -4
- package/dist/index.cjs +220 -29
- 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 +217 -28
- 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 {
|
|
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-sSzx9O1u.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 {
|
|
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-sSzx9O1u.js';
|
package/dist/index.js
CHANGED
|
@@ -502,6 +502,132 @@ 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
|
+
// Git SSH transport and TLS configuration. These are commonly required for
|
|
537
|
+
// fetch/push to keep working under the default allowlist. They are transport
|
|
538
|
+
// configuration rather than credential stores, but note they can still carry
|
|
539
|
+
// sensitive data depending on local setup (e.g. GIT_SSH_COMMAND can name a command
|
|
540
|
+
// Git executes). The most credential-prone / askpass variables (GIT_ASKPASS,
|
|
541
|
+
// SSH_ASKPASS, GIT_PROXY_COMMAND) are intentionally NOT inherited by default — they
|
|
542
|
+
// can carry inline credentials or run a helper that reads secrets from the
|
|
543
|
+
// environment, which would weaken the traversal-prevention model. Opt into those
|
|
544
|
+
// explicitly via `inheritEnv` when needed.
|
|
545
|
+
"GIT_SSH",
|
|
546
|
+
"GIT_SSH_COMMAND",
|
|
547
|
+
"GIT_SSH_VARIANT",
|
|
548
|
+
"GIT_SSL_CAINFO",
|
|
549
|
+
"GIT_SSL_CAPATH",
|
|
550
|
+
"GIT_TERMINAL_PROMPT",
|
|
551
|
+
"GIT_CONFIG_NOSYSTEM",
|
|
552
|
+
// HTTP(S) proxy configuration (required for Git network operations behind a proxy)
|
|
553
|
+
"HTTP_PROXY",
|
|
554
|
+
"HTTPS_PROXY",
|
|
555
|
+
"http_proxy",
|
|
556
|
+
"https_proxy",
|
|
557
|
+
"ALL_PROXY",
|
|
558
|
+
"all_proxy",
|
|
559
|
+
"NO_PROXY",
|
|
560
|
+
"no_proxy",
|
|
561
|
+
// Windows essentials
|
|
562
|
+
"USERPROFILE",
|
|
563
|
+
"HOMEDRIVE",
|
|
564
|
+
"HOMEPATH",
|
|
565
|
+
"APPDATA",
|
|
566
|
+
"LOCALAPPDATA",
|
|
567
|
+
"PROGRAMDATA",
|
|
568
|
+
"ALLUSERSPROFILE",
|
|
569
|
+
"PROGRAMFILES",
|
|
570
|
+
"PROGRAMFILES(X86)",
|
|
571
|
+
"PROGRAMW6432",
|
|
572
|
+
"PUBLIC",
|
|
573
|
+
"SYSTEMROOT",
|
|
574
|
+
"SYSTEMDRIVE",
|
|
575
|
+
"WINDIR",
|
|
576
|
+
"COMSPEC",
|
|
577
|
+
"COMPUTERNAME",
|
|
578
|
+
"USERDOMAIN",
|
|
579
|
+
"NUMBER_OF_PROCESSORS",
|
|
580
|
+
"PROCESSOR_ARCHITECTURE"
|
|
581
|
+
];
|
|
582
|
+
function pickEnv(parentEnv, predicate) {
|
|
583
|
+
const result = {};
|
|
584
|
+
for (const [key, value] of Object.entries(parentEnv)) {
|
|
585
|
+
if (value !== void 0 && predicate(key)) {
|
|
586
|
+
result[key] = value;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
return result;
|
|
590
|
+
}
|
|
591
|
+
function buildAllowlist(inheritEnv) {
|
|
592
|
+
const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
|
|
593
|
+
if (Array.isArray(inheritEnv)) {
|
|
594
|
+
for (const name of inheritEnv) {
|
|
595
|
+
allow.add(name);
|
|
596
|
+
}
|
|
597
|
+
return { allow, remove: void 0 };
|
|
598
|
+
}
|
|
599
|
+
if (inheritEnv === false) {
|
|
600
|
+
return { allow, remove: void 0 };
|
|
601
|
+
}
|
|
602
|
+
for (const name of inheritEnv.add ?? []) {
|
|
603
|
+
allow.add(name);
|
|
604
|
+
}
|
|
605
|
+
const hasRemove = inheritEnv.remove !== void 0 && inheritEnv.remove.length > 0;
|
|
606
|
+
const remove = hasRemove ? new Set(inheritEnv.remove) : void 0;
|
|
607
|
+
return { allow, remove };
|
|
608
|
+
}
|
|
609
|
+
function makeNameMatcher(names, isWindows) {
|
|
610
|
+
if (!isWindows) {
|
|
611
|
+
return (name) => names.has(name);
|
|
612
|
+
}
|
|
613
|
+
const lower = new Set([...names].map((name) => name.toLowerCase()));
|
|
614
|
+
return (name) => lower.has(name.toLowerCase());
|
|
615
|
+
}
|
|
616
|
+
function resolveInheritedEnv(parentEnv, inheritEnv, platform = "") {
|
|
617
|
+
if (inheritEnv === true) {
|
|
618
|
+
return pickEnv(parentEnv, () => true);
|
|
619
|
+
}
|
|
620
|
+
if (typeof inheritEnv === "function") {
|
|
621
|
+
return pickEnv(parentEnv, inheritEnv);
|
|
622
|
+
}
|
|
623
|
+
const { allow, remove } = buildAllowlist(inheritEnv ?? []);
|
|
624
|
+
const isWindows = platform === "win32";
|
|
625
|
+
const isAllowed = makeNameMatcher(allow, isWindows);
|
|
626
|
+
const isRemoved = remove ? makeNameMatcher(remove, isWindows) : () => false;
|
|
627
|
+
return pickEnv(parentEnv, (name) => isAllowed(name) && !isRemoved(name));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// src/runner/cli-runner.ts
|
|
505
631
|
var FATAL_ERROR_PATTERN = /fatal:\s*(.+)/i;
|
|
506
632
|
var ERROR_PATTERN = /error:\s*(.+)/i;
|
|
507
633
|
var LINE_SEPARATOR_PATTERN = /\r|\n/;
|
|
@@ -555,6 +681,7 @@ var CliRunner = class _CliRunner {
|
|
|
555
681
|
exec;
|
|
556
682
|
gitBinary;
|
|
557
683
|
baseEnv;
|
|
684
|
+
inheritEnv;
|
|
558
685
|
pathPrefix;
|
|
559
686
|
home;
|
|
560
687
|
credential;
|
|
@@ -563,6 +690,7 @@ var CliRunner = class _CliRunner {
|
|
|
563
690
|
this.exec = adapters.exec;
|
|
564
691
|
this.gitBinary = options?.gitBinary ?? "git";
|
|
565
692
|
this.baseEnv = options?.env ?? {};
|
|
693
|
+
this.inheritEnv = options?.inheritEnv;
|
|
566
694
|
this.pathPrefix = options?.pathPrefix ?? [];
|
|
567
695
|
this.home = options?.home;
|
|
568
696
|
this.credential = options?.credential;
|
|
@@ -576,6 +704,7 @@ var CliRunner = class _CliRunner {
|
|
|
576
704
|
withOptions(options) {
|
|
577
705
|
const mergedEnv = { ...this.baseEnv, ...options.env };
|
|
578
706
|
const mergedPathPrefix = [...this.pathPrefix, ...options.pathPrefix ?? []];
|
|
707
|
+
const inheritEnv = options.inheritEnv ?? this.inheritEnv;
|
|
579
708
|
const home = options.home ?? this.home;
|
|
580
709
|
const credential = options.credential ?? this.credential;
|
|
581
710
|
const audit = options.audit ?? this.audit;
|
|
@@ -593,6 +722,7 @@ var CliRunner = class _CliRunner {
|
|
|
593
722
|
{
|
|
594
723
|
gitBinary: options.gitBinary ?? this.gitBinary,
|
|
595
724
|
env: mergedEnv,
|
|
725
|
+
inheritEnv,
|
|
596
726
|
pathPrefix: mergedPathPrefix,
|
|
597
727
|
home,
|
|
598
728
|
credential,
|
|
@@ -624,10 +754,16 @@ var CliRunner = class _CliRunner {
|
|
|
624
754
|
/**
|
|
625
755
|
* Build the effective environment for command execution
|
|
626
756
|
*
|
|
627
|
-
*
|
|
757
|
+
* Seeds the environment from the inherited (allowlisted) parent variables, then layers
|
|
758
|
+
* the configured `env`, home directory, and PATH prefix overrides on top. The parent
|
|
759
|
+
* process environment is never forwarded wholesale unless `inheritEnv: true` is set
|
|
760
|
+
* (environment variable traversal prevention).
|
|
628
761
|
*/
|
|
629
762
|
buildEnv() {
|
|
630
|
-
const env = {
|
|
763
|
+
const env = {
|
|
764
|
+
...resolveInheritedEnv(process2.env, this.inheritEnv, process2.platform),
|
|
765
|
+
...this.baseEnv
|
|
766
|
+
};
|
|
631
767
|
if (this.home) {
|
|
632
768
|
env.HOME = this.home;
|
|
633
769
|
env.USERPROFILE = this.home;
|
|
@@ -640,9 +776,11 @@ var CliRunner = class _CliRunner {
|
|
|
640
776
|
}
|
|
641
777
|
}
|
|
642
778
|
if (allPathPrefixes.length > 0) {
|
|
643
|
-
const
|
|
644
|
-
const
|
|
645
|
-
|
|
779
|
+
const isWindows = process2.platform === "win32";
|
|
780
|
+
const separator = isWindows ? ";" : ":";
|
|
781
|
+
const pathKey = isWindows ? Object.keys(env).find((key) => key.toLowerCase() === "path") ?? "PATH" : "PATH";
|
|
782
|
+
const currentPath = env[pathKey] ?? "";
|
|
783
|
+
env[pathKey] = [...allPathPrefixes, currentPath].join(separator);
|
|
646
784
|
}
|
|
647
785
|
if (this.audit?.onTrace) {
|
|
648
786
|
if (env.GIT_TRACE === void 0) {
|
|
@@ -671,8 +809,11 @@ var CliRunner = class _CliRunner {
|
|
|
671
809
|
*/
|
|
672
810
|
async run(context, args, opts) {
|
|
673
811
|
const argv = this.buildArgv(context, args);
|
|
674
|
-
const { signal, onProgress, onLfsProgress } = opts ?? {};
|
|
812
|
+
const { signal, onProgress, onLfsProgress, env: envOverride } = opts ?? {};
|
|
675
813
|
const env = this.buildEnv();
|
|
814
|
+
if (envOverride) {
|
|
815
|
+
Object.assign(env, envOverride);
|
|
816
|
+
}
|
|
676
817
|
if (onLfsProgress) {
|
|
677
818
|
env.GIT_LFS_FORCE_PROGRESS = "1";
|
|
678
819
|
}
|
|
@@ -693,6 +834,9 @@ var CliRunner = class _CliRunner {
|
|
|
693
834
|
{
|
|
694
835
|
argv,
|
|
695
836
|
env,
|
|
837
|
+
// The env above is already fully resolved (including any inherited variables),
|
|
838
|
+
// so the adapter must not merge the parent environment on top of it.
|
|
839
|
+
inheritEnv: false,
|
|
696
840
|
cwd: context.type === "worktree" ? context.workdir : void 0,
|
|
697
841
|
signal
|
|
698
842
|
},
|
|
@@ -1237,7 +1381,7 @@ var BareRepoImpl = class {
|
|
|
1237
1381
|
*/
|
|
1238
1382
|
async push(opts) {
|
|
1239
1383
|
const args = ["push"];
|
|
1240
|
-
if (opts?.onProgress) {
|
|
1384
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
1241
1385
|
args.push("--progress");
|
|
1242
1386
|
}
|
|
1243
1387
|
if (opts?.force) {
|
|
@@ -2135,7 +2279,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2135
2279
|
*/
|
|
2136
2280
|
async push(opts) {
|
|
2137
2281
|
const args = ["push"];
|
|
2138
|
-
if (opts?.onProgress) {
|
|
2282
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2139
2283
|
args.push("--progress");
|
|
2140
2284
|
}
|
|
2141
2285
|
if (opts?.verbose) {
|
|
@@ -2240,6 +2384,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2240
2384
|
setLfsMode(mode) {
|
|
2241
2385
|
this._lfsMode = mode;
|
|
2242
2386
|
}
|
|
2387
|
+
/**
|
|
2388
|
+
* Per-command environment overrides derived from the configured LFS mode.
|
|
2389
|
+
*
|
|
2390
|
+
* When the repository was opened (or reconfigured) with an object-form LFS
|
|
2391
|
+
* mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
|
|
2392
|
+
* operations (checkout, switch, reset, merge, pull, rebase, restore) run with
|
|
2393
|
+
* `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
|
|
2394
|
+
* of downloading their contents during the implicit checkout.
|
|
2395
|
+
*
|
|
2396
|
+
* The objects can be materialized later via the explicit `repo.lfs.pull()` /
|
|
2397
|
+
* `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
|
|
2398
|
+
* not affected by `GIT_LFS_SKIP_SMUDGE`.
|
|
2399
|
+
*
|
|
2400
|
+
* Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
|
|
2401
|
+
* runner environment is left untouched.
|
|
2402
|
+
*/
|
|
2403
|
+
lfsModeEnv() {
|
|
2404
|
+
const mode = this._lfsMode;
|
|
2405
|
+
if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
|
|
2406
|
+
return { GIT_LFS_SKIP_SMUDGE: "1" };
|
|
2407
|
+
}
|
|
2408
|
+
return void 0;
|
|
2409
|
+
}
|
|
2243
2410
|
// ==========================================================================
|
|
2244
2411
|
// LFS Operations
|
|
2245
2412
|
// ==========================================================================
|
|
@@ -2262,7 +2429,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2262
2429
|
}
|
|
2263
2430
|
await this.runner.runOrThrow(this.context, args, {
|
|
2264
2431
|
signal: opts?.signal,
|
|
2265
|
-
onProgress: opts?.onProgress
|
|
2432
|
+
onProgress: opts?.onProgress,
|
|
2433
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2266
2434
|
});
|
|
2267
2435
|
}
|
|
2268
2436
|
async lfsPush(opts) {
|
|
@@ -2291,7 +2459,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2291
2459
|
}
|
|
2292
2460
|
await this.runner.runOrThrow(this.context, args, {
|
|
2293
2461
|
signal: opts?.signal,
|
|
2294
|
-
onProgress: opts?.onProgress
|
|
2462
|
+
onProgress: opts?.onProgress,
|
|
2463
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2295
2464
|
});
|
|
2296
2465
|
}
|
|
2297
2466
|
async lfsStatus(opts) {
|
|
@@ -2374,7 +2543,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2374
2543
|
const args = ["lfs", "push", remote, "--object-id", ...batch];
|
|
2375
2544
|
const result = await this.runner.run(this.context, args, {
|
|
2376
2545
|
signal: opts?.signal,
|
|
2377
|
-
onProgress: opts?.onProgress
|
|
2546
|
+
onProgress: opts?.onProgress,
|
|
2547
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2378
2548
|
});
|
|
2379
2549
|
if (result.exitCode === 0) {
|
|
2380
2550
|
uploadedCount += batch.length;
|
|
@@ -2451,7 +2621,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2451
2621
|
const args = ["lfs", "fetch", remote, "--", ...batch];
|
|
2452
2622
|
const result = await this.runner.run(this.context, args, {
|
|
2453
2623
|
signal: opts?.signal,
|
|
2454
|
-
onProgress: opts?.onProgress
|
|
2624
|
+
onProgress: opts?.onProgress,
|
|
2625
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2455
2626
|
});
|
|
2456
2627
|
if (result.exitCode === 0) {
|
|
2457
2628
|
downloadedCount += batch.length;
|
|
@@ -2516,7 +2687,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2516
2687
|
return;
|
|
2517
2688
|
}
|
|
2518
2689
|
const args = ["lfs", "fetch"];
|
|
2519
|
-
if (opts?.onProgress) {
|
|
2690
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2520
2691
|
args.push("--progress");
|
|
2521
2692
|
}
|
|
2522
2693
|
if (opts?.all) {
|
|
@@ -2549,7 +2720,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2549
2720
|
}
|
|
2550
2721
|
await this.runner.runOrThrow(this.context, args, {
|
|
2551
2722
|
signal: opts?.signal,
|
|
2552
|
-
onProgress: opts?.onProgress
|
|
2723
|
+
onProgress: opts?.onProgress,
|
|
2724
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2553
2725
|
});
|
|
2554
2726
|
}
|
|
2555
2727
|
async lfsInstall(opts) {
|
|
@@ -3311,7 +3483,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3311
3483
|
}
|
|
3312
3484
|
}
|
|
3313
3485
|
await this.runner.runOrThrow(this.context, args, {
|
|
3314
|
-
signal: opts?.signal
|
|
3486
|
+
signal: opts?.signal,
|
|
3487
|
+
env: this.lfsModeEnv()
|
|
3315
3488
|
});
|
|
3316
3489
|
}
|
|
3317
3490
|
// ==========================================================================
|
|
@@ -3668,7 +3841,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3668
3841
|
}
|
|
3669
3842
|
args.push(branch);
|
|
3670
3843
|
const result = await this.runner.run(this.context, args, {
|
|
3671
|
-
signal: opts?.signal
|
|
3844
|
+
signal: opts?.signal,
|
|
3845
|
+
env: this.lfsModeEnv()
|
|
3672
3846
|
});
|
|
3673
3847
|
if (result.exitCode !== 0) {
|
|
3674
3848
|
const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
|
|
@@ -3697,7 +3871,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3697
3871
|
// ==========================================================================
|
|
3698
3872
|
async pull(opts) {
|
|
3699
3873
|
const args = ["pull"];
|
|
3700
|
-
if (opts?.onProgress) {
|
|
3874
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
3701
3875
|
args.push("--progress");
|
|
3702
3876
|
}
|
|
3703
3877
|
if (opts?.rebase === true) {
|
|
@@ -3845,7 +4019,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3845
4019
|
}
|
|
3846
4020
|
await this.runner.runOrThrow(this.context, args, {
|
|
3847
4021
|
signal: opts?.signal,
|
|
3848
|
-
onProgress: opts?.onProgress
|
|
4022
|
+
onProgress: opts?.onProgress,
|
|
4023
|
+
onLfsProgress: opts?.onLfsProgress,
|
|
4024
|
+
env: this.lfsModeEnv()
|
|
3849
4025
|
});
|
|
3850
4026
|
}
|
|
3851
4027
|
// ==========================================================================
|
|
@@ -3875,7 +4051,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3875
4051
|
args.push(target);
|
|
3876
4052
|
}
|
|
3877
4053
|
await this.runner.runOrThrow(this.context, args, {
|
|
3878
|
-
signal: opts?.signal
|
|
4054
|
+
signal: opts?.signal,
|
|
4055
|
+
env: this.lfsModeEnv()
|
|
3879
4056
|
});
|
|
3880
4057
|
}
|
|
3881
4058
|
// ==========================================================================
|
|
@@ -4071,7 +4248,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4071
4248
|
args.push(opts.startPoint);
|
|
4072
4249
|
}
|
|
4073
4250
|
await this.runner.runOrThrow(this.context, args, {
|
|
4074
|
-
signal: opts?.signal
|
|
4251
|
+
signal: opts?.signal,
|
|
4252
|
+
env: this.lfsModeEnv()
|
|
4075
4253
|
});
|
|
4076
4254
|
}
|
|
4077
4255
|
// ==========================================================================
|
|
@@ -4498,7 +4676,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4498
4676
|
args.push(opts.upstream);
|
|
4499
4677
|
}
|
|
4500
4678
|
await this.runner.runOrThrow(this.context, args, {
|
|
4501
|
-
signal: opts?.signal
|
|
4679
|
+
signal: opts?.signal,
|
|
4680
|
+
env: this.lfsModeEnv()
|
|
4502
4681
|
});
|
|
4503
4682
|
}
|
|
4504
4683
|
// ==========================================================================
|
|
@@ -4556,7 +4735,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4556
4735
|
const pathList = Array.isArray(paths) ? paths : [paths];
|
|
4557
4736
|
args.push("--", ...pathList);
|
|
4558
4737
|
await this.runner.runOrThrow(this.context, args, {
|
|
4559
|
-
signal: opts?.signal
|
|
4738
|
+
signal: opts?.signal,
|
|
4739
|
+
env: this.lfsModeEnv()
|
|
4560
4740
|
});
|
|
4561
4741
|
}
|
|
4562
4742
|
// ==========================================================================
|
|
@@ -5467,6 +5647,7 @@ function toCliRunnerOptions(opts) {
|
|
|
5467
5647
|
}
|
|
5468
5648
|
return {
|
|
5469
5649
|
env: opts.env,
|
|
5650
|
+
inheritEnv: opts.inheritEnv,
|
|
5470
5651
|
pathPrefix: opts.pathPrefix,
|
|
5471
5652
|
home: opts.home,
|
|
5472
5653
|
credential: opts.credential ? {
|
|
@@ -5568,7 +5749,7 @@ var GitImpl = class {
|
|
|
5568
5749
|
}
|
|
5569
5750
|
async clone(url, path, opts) {
|
|
5570
5751
|
const args = buildCloneArgs(opts);
|
|
5571
|
-
if (opts?.onProgress) {
|
|
5752
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
5572
5753
|
args.push("--progress");
|
|
5573
5754
|
}
|
|
5574
5755
|
args.push(url, path);
|
|
@@ -5910,6 +6091,12 @@ async function createGit(options) {
|
|
|
5910
6091
|
|
|
5911
6092
|
// src/adapters/node/exec.ts
|
|
5912
6093
|
import { spawn } from "child_process";
|
|
6094
|
+
function resolveChildEnv(env, inheritEnv) {
|
|
6095
|
+
if (inheritEnv === false) {
|
|
6096
|
+
return env ?? {};
|
|
6097
|
+
}
|
|
6098
|
+
return env ? { ...process.env, ...env } : process.env;
|
|
6099
|
+
}
|
|
5913
6100
|
async function* streamToAsyncIterable(stream) {
|
|
5914
6101
|
let buffer = "";
|
|
5915
6102
|
for await (const chunk of stream) {
|
|
@@ -5936,7 +6123,7 @@ var NodeExecAdapter = class {
|
|
|
5936
6123
|
};
|
|
5937
6124
|
}
|
|
5938
6125
|
spawn(options, handlers) {
|
|
5939
|
-
const { argv, env, cwd, signal } = options;
|
|
6126
|
+
const { argv, env, inheritEnv, cwd, signal } = options;
|
|
5940
6127
|
const command = argv[0];
|
|
5941
6128
|
if (command === void 0) {
|
|
5942
6129
|
throw new Error("argv must not be empty");
|
|
@@ -5945,7 +6132,7 @@ var NodeExecAdapter = class {
|
|
|
5945
6132
|
return new Promise((resolve, reject) => {
|
|
5946
6133
|
const child = spawn(command, args, {
|
|
5947
6134
|
cwd,
|
|
5948
|
-
env: env
|
|
6135
|
+
env: resolveChildEnv(env, inheritEnv),
|
|
5949
6136
|
stdio: ["ignore", "pipe", "pipe"]
|
|
5950
6137
|
});
|
|
5951
6138
|
let stdout = "";
|
|
@@ -5993,7 +6180,7 @@ var NodeExecAdapter = class {
|
|
|
5993
6180
|
});
|
|
5994
6181
|
}
|
|
5995
6182
|
spawnStreaming(options) {
|
|
5996
|
-
const { argv, env, cwd, signal } = options;
|
|
6183
|
+
const { argv, env, inheritEnv, cwd, signal } = options;
|
|
5997
6184
|
const command = argv[0];
|
|
5998
6185
|
if (command === void 0) {
|
|
5999
6186
|
throw new Error("argv must not be empty");
|
|
@@ -6001,7 +6188,7 @@ var NodeExecAdapter = class {
|
|
|
6001
6188
|
const args = argv.slice(1);
|
|
6002
6189
|
const child = spawn(command, args, {
|
|
6003
6190
|
cwd,
|
|
6004
|
-
env: env
|
|
6191
|
+
env: resolveChildEnv(env, inheritEnv),
|
|
6005
6192
|
stdio: ["ignore", "pipe", "pipe"]
|
|
6006
6193
|
});
|
|
6007
6194
|
let aborted = false;
|
|
@@ -6398,6 +6585,7 @@ var TypeGit = class _TypeGit {
|
|
|
6398
6585
|
};
|
|
6399
6586
|
export {
|
|
6400
6587
|
CliRunner,
|
|
6588
|
+
DEFAULT_ENV_ALLOWLIST,
|
|
6401
6589
|
GIT_LOG_FORMAT,
|
|
6402
6590
|
GitArgumentError,
|
|
6403
6591
|
GitError,
|
|
@@ -6422,6 +6610,7 @@ export {
|
|
|
6422
6610
|
parseLsTree,
|
|
6423
6611
|
parsePorcelainV2,
|
|
6424
6612
|
parseRecords,
|
|
6425
|
-
parseWorktreeList
|
|
6613
|
+
parseWorktreeList,
|
|
6614
|
+
resolveInheritedEnv
|
|
6426
6615
|
};
|
|
6427
6616
|
//# sourceMappingURL=index.js.map
|