type-git 0.2.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/README.md +38 -0
- 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 +224 -32
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +23 -2
- package/dist/adapters/node/index.d.ts +23 -2
- package/dist/adapters/node/index.js +224 -32
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-BFRtEriX.d.cts → adapters-Bpuvmw9y.d.cts} +190 -1
- package/dist/{adapters-BFRtEriX.d.ts → adapters-Bpuvmw9y.d.ts} +190 -1
- package/dist/index.cjs +230 -34
- 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 +227 -33
- 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, 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 {
|
|
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,9 +502,103 @@ 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/;
|
|
601
|
+
var GIT_TRACE_PATTERN = /^\d{2}:\d{2}:\d{2}\.\d+\s+(?:trace:|[A-Za-z0-9_.-]+\.c:)/;
|
|
508
602
|
function toLfsProgress(info) {
|
|
509
603
|
if (!info) {
|
|
510
604
|
return null;
|
|
@@ -554,16 +648,20 @@ var CliRunner = class _CliRunner {
|
|
|
554
648
|
exec;
|
|
555
649
|
gitBinary;
|
|
556
650
|
baseEnv;
|
|
651
|
+
inheritEnv;
|
|
557
652
|
pathPrefix;
|
|
558
653
|
home;
|
|
559
654
|
credential;
|
|
655
|
+
audit;
|
|
560
656
|
constructor(adapters, options) {
|
|
561
657
|
this.exec = adapters.exec;
|
|
562
658
|
this.gitBinary = options?.gitBinary ?? "git";
|
|
563
659
|
this.baseEnv = options?.env ?? {};
|
|
660
|
+
this.inheritEnv = options?.inheritEnv;
|
|
564
661
|
this.pathPrefix = options?.pathPrefix ?? [];
|
|
565
662
|
this.home = options?.home;
|
|
566
663
|
this.credential = options?.credential;
|
|
664
|
+
this.audit = options?.audit;
|
|
567
665
|
}
|
|
568
666
|
/**
|
|
569
667
|
* Create a new CliRunner with additional options merged
|
|
@@ -573,8 +671,10 @@ var CliRunner = class _CliRunner {
|
|
|
573
671
|
withOptions(options) {
|
|
574
672
|
const mergedEnv = { ...this.baseEnv, ...options.env };
|
|
575
673
|
const mergedPathPrefix = [...this.pathPrefix, ...options.pathPrefix ?? []];
|
|
674
|
+
const inheritEnv = options.inheritEnv ?? this.inheritEnv;
|
|
576
675
|
const home = options.home ?? this.home;
|
|
577
676
|
const credential = options.credential ?? this.credential;
|
|
677
|
+
const audit = options.audit ?? this.audit;
|
|
578
678
|
return new _CliRunner(
|
|
579
679
|
{
|
|
580
680
|
exec: this.exec,
|
|
@@ -589,9 +689,11 @@ var CliRunner = class _CliRunner {
|
|
|
589
689
|
{
|
|
590
690
|
gitBinary: options.gitBinary ?? this.gitBinary,
|
|
591
691
|
env: mergedEnv,
|
|
692
|
+
inheritEnv,
|
|
592
693
|
pathPrefix: mergedPathPrefix,
|
|
593
694
|
home,
|
|
594
|
-
credential
|
|
695
|
+
credential,
|
|
696
|
+
audit
|
|
595
697
|
}
|
|
596
698
|
);
|
|
597
699
|
}
|
|
@@ -619,10 +721,16 @@ var CliRunner = class _CliRunner {
|
|
|
619
721
|
/**
|
|
620
722
|
* Build the effective environment for command execution
|
|
621
723
|
*
|
|
622
|
-
*
|
|
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).
|
|
623
728
|
*/
|
|
624
729
|
buildEnv() {
|
|
625
|
-
const env = {
|
|
730
|
+
const env = {
|
|
731
|
+
...resolveInheritedEnv(process2.env, this.inheritEnv, process2.platform),
|
|
732
|
+
...this.baseEnv
|
|
733
|
+
};
|
|
626
734
|
if (this.home) {
|
|
627
735
|
env.HOME = this.home;
|
|
628
736
|
env.USERPROFILE = this.home;
|
|
@@ -635,9 +743,20 @@ var CliRunner = class _CliRunner {
|
|
|
635
743
|
}
|
|
636
744
|
}
|
|
637
745
|
if (allPathPrefixes.length > 0) {
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
|
|
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);
|
|
751
|
+
}
|
|
752
|
+
if (this.audit?.onTrace) {
|
|
753
|
+
if (env.GIT_TRACE === void 0) {
|
|
754
|
+
env.GIT_TRACE = "1";
|
|
755
|
+
} else if (!env.GIT_TRACE || env.GIT_TRACE === "0") {
|
|
756
|
+
console.warn(
|
|
757
|
+
"type-git: onTrace callback provided but GIT_TRACE is disabled. Trace events will not be emitted."
|
|
758
|
+
);
|
|
759
|
+
}
|
|
641
760
|
}
|
|
642
761
|
return env;
|
|
643
762
|
}
|
|
@@ -662,27 +781,73 @@ var CliRunner = class _CliRunner {
|
|
|
662
781
|
if (onLfsProgress) {
|
|
663
782
|
env.GIT_LFS_FORCE_PROGRESS = "1";
|
|
664
783
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
{
|
|
784
|
+
const startTimestamp = Date.now();
|
|
785
|
+
if (this.audit?.onAudit) {
|
|
786
|
+
this.audit.onAudit({
|
|
787
|
+
type: "start",
|
|
788
|
+
timestamp: startTimestamp,
|
|
668
789
|
argv,
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
790
|
+
context
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
let stderrBuffer = "";
|
|
794
|
+
const needsStderrStreaming = onProgress || onLfsProgress || this.audit?.onTrace;
|
|
795
|
+
let result;
|
|
796
|
+
try {
|
|
797
|
+
result = await this.exec.spawn(
|
|
798
|
+
{
|
|
799
|
+
argv,
|
|
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,
|
|
804
|
+
cwd: context.type === "worktree" ? context.workdir : void 0,
|
|
805
|
+
signal
|
|
806
|
+
},
|
|
807
|
+
needsStderrStreaming ? {
|
|
808
|
+
onStderr: (chunk) => {
|
|
809
|
+
stderrBuffer += chunk;
|
|
810
|
+
const lines = stderrBuffer.split(LINE_SEPARATOR_PATTERN);
|
|
811
|
+
stderrBuffer = lines.pop() ?? "";
|
|
812
|
+
for (const line of lines) {
|
|
813
|
+
this.processStderrLine(line, onProgress, onLfsProgress);
|
|
814
|
+
}
|
|
680
815
|
}
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
816
|
+
} : void 0
|
|
817
|
+
);
|
|
818
|
+
if (stderrBuffer.trim() && needsStderrStreaming) {
|
|
819
|
+
this.processStderrLine(stderrBuffer, onProgress, onLfsProgress);
|
|
820
|
+
}
|
|
821
|
+
} catch (error) {
|
|
822
|
+
if (this.audit?.onAudit) {
|
|
823
|
+
const endTimestamp = Date.now();
|
|
824
|
+
this.audit.onAudit({
|
|
825
|
+
type: "end",
|
|
826
|
+
timestamp: endTimestamp,
|
|
827
|
+
argv,
|
|
828
|
+
context,
|
|
829
|
+
stdout: "",
|
|
830
|
+
stderr: error instanceof Error ? error.message : String(error),
|
|
831
|
+
exitCode: -1,
|
|
832
|
+
aborted: signal?.aborted ?? false,
|
|
833
|
+
duration: endTimestamp - startTimestamp
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
throw error;
|
|
837
|
+
}
|
|
838
|
+
if (this.audit?.onAudit) {
|
|
839
|
+
const endTimestamp = Date.now();
|
|
840
|
+
this.audit.onAudit({
|
|
841
|
+
type: "end",
|
|
842
|
+
timestamp: endTimestamp,
|
|
843
|
+
argv,
|
|
844
|
+
context,
|
|
845
|
+
stdout: result.stdout,
|
|
846
|
+
stderr: result.stderr,
|
|
847
|
+
exitCode: result.exitCode,
|
|
848
|
+
aborted: result.aborted,
|
|
849
|
+
duration: endTimestamp - startTimestamp
|
|
850
|
+
});
|
|
686
851
|
}
|
|
687
852
|
return {
|
|
688
853
|
stdout: result.stdout,
|
|
@@ -691,6 +856,23 @@ var CliRunner = class _CliRunner {
|
|
|
691
856
|
aborted: result.aborted
|
|
692
857
|
};
|
|
693
858
|
}
|
|
859
|
+
/**
|
|
860
|
+
* Process a single line from stderr for progress and trace callbacks
|
|
861
|
+
*/
|
|
862
|
+
processStderrLine(line, onProgress, onLfsProgress) {
|
|
863
|
+
const trimmed = line.trim();
|
|
864
|
+
if (!trimmed) {
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (this.audit?.onTrace && GIT_TRACE_PATTERN.test(trimmed)) {
|
|
868
|
+
this.audit.onTrace({
|
|
869
|
+
timestamp: Date.now(),
|
|
870
|
+
line: trimmed
|
|
871
|
+
});
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
processProgressLine(line, onProgress, onLfsProgress);
|
|
875
|
+
}
|
|
694
876
|
/**
|
|
695
877
|
* Map Git result to GitError if needed
|
|
696
878
|
*/
|
|
@@ -1184,7 +1366,8 @@ var BareRepoImpl = class {
|
|
|
1184
1366
|
}
|
|
1185
1367
|
await this.runner.runOrThrow(this.context, args, {
|
|
1186
1368
|
signal: opts?.signal,
|
|
1187
|
-
onProgress: opts?.onProgress
|
|
1369
|
+
onProgress: opts?.onProgress,
|
|
1370
|
+
onLfsProgress: opts?.onLfsProgress
|
|
1188
1371
|
});
|
|
1189
1372
|
}
|
|
1190
1373
|
// ==========================================================================
|
|
@@ -2155,7 +2338,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2155
2338
|
}
|
|
2156
2339
|
await this.runner.runOrThrow(this.context, args, {
|
|
2157
2340
|
signal: opts?.signal,
|
|
2158
|
-
onProgress: opts?.onProgress
|
|
2341
|
+
onProgress: opts?.onProgress,
|
|
2342
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2159
2343
|
});
|
|
2160
2344
|
}
|
|
2161
2345
|
/**
|
|
@@ -5391,6 +5575,7 @@ function toCliRunnerOptions(opts) {
|
|
|
5391
5575
|
}
|
|
5392
5576
|
return {
|
|
5393
5577
|
env: opts.env,
|
|
5578
|
+
inheritEnv: opts.inheritEnv,
|
|
5394
5579
|
pathPrefix: opts.pathPrefix,
|
|
5395
5580
|
home: opts.home,
|
|
5396
5581
|
credential: opts.credential ? {
|
|
@@ -5499,7 +5684,8 @@ var GitImpl = class {
|
|
|
5499
5684
|
try {
|
|
5500
5685
|
await this.runner.runOrThrow({ type: "global" }, args, {
|
|
5501
5686
|
signal: opts?.signal,
|
|
5502
|
-
onProgress: opts?.onProgress
|
|
5687
|
+
onProgress: opts?.onProgress,
|
|
5688
|
+
onLfsProgress: opts?.onLfsProgress
|
|
5503
5689
|
});
|
|
5504
5690
|
} catch (error) {
|
|
5505
5691
|
if (error instanceof GitError && error.kind === "Aborted" && opts?.cleanupOnAbort !== false) {
|
|
@@ -5833,6 +6019,12 @@ async function createGit(options) {
|
|
|
5833
6019
|
|
|
5834
6020
|
// src/adapters/node/exec.ts
|
|
5835
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
|
+
}
|
|
5836
6028
|
async function* streamToAsyncIterable(stream) {
|
|
5837
6029
|
let buffer = "";
|
|
5838
6030
|
for await (const chunk of stream) {
|
|
@@ -5859,7 +6051,7 @@ var NodeExecAdapter = class {
|
|
|
5859
6051
|
};
|
|
5860
6052
|
}
|
|
5861
6053
|
spawn(options, handlers) {
|
|
5862
|
-
const { argv, env, cwd, signal } = options;
|
|
6054
|
+
const { argv, env, inheritEnv, cwd, signal } = options;
|
|
5863
6055
|
const command = argv[0];
|
|
5864
6056
|
if (command === void 0) {
|
|
5865
6057
|
throw new Error("argv must not be empty");
|
|
@@ -5868,7 +6060,7 @@ var NodeExecAdapter = class {
|
|
|
5868
6060
|
return new Promise((resolve, reject) => {
|
|
5869
6061
|
const child = spawn(command, args, {
|
|
5870
6062
|
cwd,
|
|
5871
|
-
env: env
|
|
6063
|
+
env: resolveChildEnv(env, inheritEnv),
|
|
5872
6064
|
stdio: ["ignore", "pipe", "pipe"]
|
|
5873
6065
|
});
|
|
5874
6066
|
let stdout = "";
|
|
@@ -5916,7 +6108,7 @@ var NodeExecAdapter = class {
|
|
|
5916
6108
|
});
|
|
5917
6109
|
}
|
|
5918
6110
|
spawnStreaming(options) {
|
|
5919
|
-
const { argv, env, cwd, signal } = options;
|
|
6111
|
+
const { argv, env, inheritEnv, cwd, signal } = options;
|
|
5920
6112
|
const command = argv[0];
|
|
5921
6113
|
if (command === void 0) {
|
|
5922
6114
|
throw new Error("argv must not be empty");
|
|
@@ -5924,7 +6116,7 @@ var NodeExecAdapter = class {
|
|
|
5924
6116
|
const args = argv.slice(1);
|
|
5925
6117
|
const child = spawn(command, args, {
|
|
5926
6118
|
cwd,
|
|
5927
|
-
env: env
|
|
6119
|
+
env: resolveChildEnv(env, inheritEnv),
|
|
5928
6120
|
stdio: ["ignore", "pipe", "pipe"]
|
|
5929
6121
|
});
|
|
5930
6122
|
let aborted = false;
|
|
@@ -6321,6 +6513,7 @@ var TypeGit = class _TypeGit {
|
|
|
6321
6513
|
};
|
|
6322
6514
|
export {
|
|
6323
6515
|
CliRunner,
|
|
6516
|
+
DEFAULT_ENV_ALLOWLIST,
|
|
6324
6517
|
GIT_LOG_FORMAT,
|
|
6325
6518
|
GitArgumentError,
|
|
6326
6519
|
GitError,
|
|
@@ -6345,6 +6538,7 @@ export {
|
|
|
6345
6538
|
parseLsTree,
|
|
6346
6539
|
parsePorcelainV2,
|
|
6347
6540
|
parseRecords,
|
|
6348
|
-
parseWorktreeList
|
|
6541
|
+
parseWorktreeList,
|
|
6542
|
+
resolveInheritedEnv
|
|
6349
6543
|
};
|
|
6350
6544
|
//# sourceMappingURL=index.js.map
|