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.
- package/dist/adapters/bun/index.d.cts +1 -1
- package/dist/adapters/bun/index.d.ts +1 -1
- package/dist/adapters/deno/index.d.cts +1 -1
- package/dist/adapters/deno/index.d.ts +1 -1
- package/dist/adapters/node/index.cjs +110 -38
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +20 -3
- package/dist/adapters/node/index.d.ts +20 -3
- package/dist/adapters/node/index.js +110 -38
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-Bpuvmw9y.d.cts → adapters-sSzx9O1u.d.cts} +58 -8
- package/dist/{adapters-Bpuvmw9y.d.ts → adapters-sSzx9O1u.d.ts} +58 -8
- package/dist/index.cjs +110 -38
- 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 +110 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,31 @@
|
|
|
11
11
|
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
12
|
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fine-grained adjustment of the default allowlist.
|
|
16
|
+
*
|
|
17
|
+
* Starts from {@link DEFAULT_ENV_ALLOWLIST}, adds the names in `add`, then removes the
|
|
18
|
+
* names in `remove`. `remove` takes precedence, so `{ add: ['X'], remove: ['X'] }`
|
|
19
|
+
* excludes `X`. This is the way to drop a single default entry (for example
|
|
20
|
+
* `{ remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }` for an HTTPS-only application) while
|
|
21
|
+
* keeping the rest of the curated defaults.
|
|
22
|
+
*/
|
|
23
|
+
type EnvAllowlistAdjustment = {
|
|
24
|
+
/** Variable names to add to the default allowlist. */
|
|
25
|
+
add?: string[];
|
|
26
|
+
/** Variable names to remove from the (default + add) allowlist. */
|
|
27
|
+
remove?: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Predicate deciding, per variable, whether it is inherited from the parent environment.
|
|
31
|
+
* Receives each parent environment variable name and returns `true` to inherit it. This
|
|
32
|
+
* gives full control and bypasses the default allowlist entirely — reference
|
|
33
|
+
* {@link DEFAULT_ENV_ALLOWLIST} explicitly if you want to build on top of it.
|
|
34
|
+
*
|
|
35
|
+
* Note: on Windows the name is passed through as-is, so handle case-insensitivity yourself
|
|
36
|
+
* (e.g. compare against `name.toUpperCase()`).
|
|
37
|
+
*/
|
|
38
|
+
type EnvInheritancePredicate = (name: string) => boolean;
|
|
14
39
|
/**
|
|
15
40
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
41
|
*
|
|
@@ -22,8 +47,12 @@
|
|
|
22
47
|
* break Git if `PATH` is not otherwise supplied.
|
|
23
48
|
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
49
|
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
50
|
+
* - `{ add?, remove? }`: inherit {@link DEFAULT_ENV_ALLOWLIST}, plus `add`, minus `remove`.
|
|
51
|
+
* Use this to drop a single default entry without rebuilding the whole allowlist.
|
|
52
|
+
* - `(name) => boolean`: a predicate that decides each variable individually, bypassing the
|
|
53
|
+
* default allowlist entirely.
|
|
25
54
|
*/
|
|
26
|
-
type EnvInheritance = boolean | string[];
|
|
55
|
+
type EnvInheritance = boolean | string[] | EnvAllowlistAdjustment | EnvInheritancePredicate;
|
|
27
56
|
/**
|
|
28
57
|
* Curated allowlist of environment variables inherited by default.
|
|
29
58
|
*
|
|
@@ -31,6 +60,16 @@ type EnvInheritance = boolean | string[];
|
|
|
31
60
|
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
61
|
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
62
|
*
|
|
63
|
+
* Security notes:
|
|
64
|
+
* - The SSH agent vars (`SSH_AUTH_SOCK`, `SSH_AGENT_PID`) and SSH/TLS transport config
|
|
65
|
+
* (`GIT_SSH_COMMAND`, `GIT_SSL_CAINFO`, …) are inherited by default so Git-over-SSH and
|
|
66
|
+
* fetch/push keep working out of the box. For an HTTPS-only application that does not
|
|
67
|
+
* want to expose the SSH agent, drop it with
|
|
68
|
+
* `inheritEnv: { remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }`.
|
|
69
|
+
* - The most credential-prone helpers (`GIT_ASKPASS`, `SSH_ASKPASS`, `GIT_PROXY_COMMAND`)
|
|
70
|
+
* are intentionally NOT in the default allowlist; opt them back in explicitly
|
|
71
|
+
* (`inheritEnv: ['GIT_ASKPASS']`) only when you trust the value.
|
|
72
|
+
*
|
|
34
73
|
* Variable names are matched case-insensitively on Windows.
|
|
35
74
|
*/
|
|
36
75
|
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
@@ -296,12 +335,20 @@ type Capabilities = {
|
|
|
296
335
|
lfsVersion?: string;
|
|
297
336
|
};
|
|
298
337
|
/**
|
|
299
|
-
* LFS mode configuration
|
|
338
|
+
* LFS mode configuration.
|
|
339
|
+
*
|
|
340
|
+
* - `'enabled'` (default): LFS behaves normally.
|
|
341
|
+
* - `'disabled'`: the `repo.lfs.*` / `repo.lfsExtra.*` helpers become no-ops.
|
|
342
|
+
* - object form: working-tree-populating operations (`checkout`, `switch`,
|
|
343
|
+
* `reset`, `merge`, `pull`, `rebase`, `restore`) run with
|
|
344
|
+
* `GIT_LFS_SKIP_SMUDGE=1` so Git leaves LFS pointer files in place instead of
|
|
345
|
+
* downloading their contents. The objects can be materialized later via the
|
|
346
|
+
* explicit `repo.lfs.pull()` / `repo.lfs.checkout()` helpers.
|
|
300
347
|
*/
|
|
301
348
|
type LfsMode = 'enabled' | 'disabled' | {
|
|
302
|
-
/** Skip smudge filter (don't download LFS files on checkout) */
|
|
349
|
+
/** Skip smudge filter (don't download LFS files on checkout). */
|
|
303
350
|
skipSmudge?: boolean;
|
|
304
|
-
/** Skip download
|
|
351
|
+
/** Skip download, keeping pointer files (also implies skip-smudge). */
|
|
305
352
|
skipDownload?: boolean;
|
|
306
353
|
};
|
|
307
354
|
/**
|
|
@@ -383,9 +430,12 @@ type GitOpenOptions = {
|
|
|
383
430
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
431
|
*
|
|
385
432
|
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
-
* inherited (environment variable traversal prevention).
|
|
387
|
-
*
|
|
388
|
-
*
|
|
433
|
+
* inherited (environment variable traversal prevention). See {@link EnvInheritance} for
|
|
434
|
+
* all supported forms:
|
|
435
|
+
* - `true` — inherit the full parent environment.
|
|
436
|
+
* - `string[]` — inherit the default allowlist plus the named variables.
|
|
437
|
+
* - `{ add?, remove? }` — adjust the default allowlist (e.g. drop `SSH_AUTH_SOCK`).
|
|
438
|
+
* - `(name) => boolean` — decide each variable individually.
|
|
389
439
|
*/
|
|
390
440
|
inheritEnv?: EnvInheritance;
|
|
391
441
|
/** Directories to prepend to PATH */
|
|
@@ -795,4 +845,4 @@ interface RuntimeAdapters {
|
|
|
795
845
|
*/
|
|
796
846
|
type AdapterFactory = () => RuntimeAdapters;
|
|
797
847
|
|
|
798
|
-
export { type AuditConfig as A, type
|
|
848
|
+
export { type AuditConfig as A, type AuditEventEnd as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type AuditEvent as H, type TraceEvent as I, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, type EnvAllowlistAdjustment as m, type EnvInheritancePredicate as n, nonEmpty as o, isNonEmpty as p, type LfsProgress as q, resolveInheritedEnv as r, type GitErrorKind as s, GitArgumentError as t, type Runtime as u, type CommandSpec as v, type CredentialRequest as w, type Credential as x, type CredentialConfig as y, type AuditEventStart as z };
|
|
@@ -11,6 +11,31 @@
|
|
|
11
11
|
* Instead, only a curated allowlist of variables that Git genuinely needs to operate is
|
|
12
12
|
* inherited. Callers can widen or replace this behavior via the `inheritEnv` option.
|
|
13
13
|
*/
|
|
14
|
+
/**
|
|
15
|
+
* Fine-grained adjustment of the default allowlist.
|
|
16
|
+
*
|
|
17
|
+
* Starts from {@link DEFAULT_ENV_ALLOWLIST}, adds the names in `add`, then removes the
|
|
18
|
+
* names in `remove`. `remove` takes precedence, so `{ add: ['X'], remove: ['X'] }`
|
|
19
|
+
* excludes `X`. This is the way to drop a single default entry (for example
|
|
20
|
+
* `{ remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }` for an HTTPS-only application) while
|
|
21
|
+
* keeping the rest of the curated defaults.
|
|
22
|
+
*/
|
|
23
|
+
type EnvAllowlistAdjustment = {
|
|
24
|
+
/** Variable names to add to the default allowlist. */
|
|
25
|
+
add?: string[];
|
|
26
|
+
/** Variable names to remove from the (default + add) allowlist. */
|
|
27
|
+
remove?: string[];
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Predicate deciding, per variable, whether it is inherited from the parent environment.
|
|
31
|
+
* Receives each parent environment variable name and returns `true` to inherit it. This
|
|
32
|
+
* gives full control and bypasses the default allowlist entirely — reference
|
|
33
|
+
* {@link DEFAULT_ENV_ALLOWLIST} explicitly if you want to build on top of it.
|
|
34
|
+
*
|
|
35
|
+
* Note: on Windows the name is passed through as-is, so handle case-insensitivity yourself
|
|
36
|
+
* (e.g. compare against `name.toUpperCase()`).
|
|
37
|
+
*/
|
|
38
|
+
type EnvInheritancePredicate = (name: string) => boolean;
|
|
14
39
|
/**
|
|
15
40
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
16
41
|
*
|
|
@@ -22,8 +47,12 @@
|
|
|
22
47
|
* break Git if `PATH` is not otherwise supplied.
|
|
23
48
|
* - `string[]`: inherit {@link DEFAULT_ENV_ALLOWLIST} plus the named variables. Use this
|
|
24
49
|
* to explicitly opt specific variables (e.g. an SSH command or a token) back in.
|
|
50
|
+
* - `{ add?, remove? }`: inherit {@link DEFAULT_ENV_ALLOWLIST}, plus `add`, minus `remove`.
|
|
51
|
+
* Use this to drop a single default entry without rebuilding the whole allowlist.
|
|
52
|
+
* - `(name) => boolean`: a predicate that decides each variable individually, bypassing the
|
|
53
|
+
* default allowlist entirely.
|
|
25
54
|
*/
|
|
26
|
-
type EnvInheritance = boolean | string[];
|
|
55
|
+
type EnvInheritance = boolean | string[] | EnvAllowlistAdjustment | EnvInheritancePredicate;
|
|
27
56
|
/**
|
|
28
57
|
* Curated allowlist of environment variables inherited by default.
|
|
29
58
|
*
|
|
@@ -31,6 +60,16 @@ type EnvInheritance = boolean | string[];
|
|
|
31
60
|
* helpers) commonly needs to operate. The list intentionally excludes arbitrary
|
|
32
61
|
* application secrets so they are not silently forwarded to Git subprocesses.
|
|
33
62
|
*
|
|
63
|
+
* Security notes:
|
|
64
|
+
* - The SSH agent vars (`SSH_AUTH_SOCK`, `SSH_AGENT_PID`) and SSH/TLS transport config
|
|
65
|
+
* (`GIT_SSH_COMMAND`, `GIT_SSL_CAINFO`, …) are inherited by default so Git-over-SSH and
|
|
66
|
+
* fetch/push keep working out of the box. For an HTTPS-only application that does not
|
|
67
|
+
* want to expose the SSH agent, drop it with
|
|
68
|
+
* `inheritEnv: { remove: ['SSH_AUTH_SOCK', 'SSH_AGENT_PID'] }`.
|
|
69
|
+
* - The most credential-prone helpers (`GIT_ASKPASS`, `SSH_ASKPASS`, `GIT_PROXY_COMMAND`)
|
|
70
|
+
* are intentionally NOT in the default allowlist; opt them back in explicitly
|
|
71
|
+
* (`inheritEnv: ['GIT_ASKPASS']`) only when you trust the value.
|
|
72
|
+
*
|
|
34
73
|
* Variable names are matched case-insensitively on Windows.
|
|
35
74
|
*/
|
|
36
75
|
declare const DEFAULT_ENV_ALLOWLIST: readonly string[];
|
|
@@ -296,12 +335,20 @@ type Capabilities = {
|
|
|
296
335
|
lfsVersion?: string;
|
|
297
336
|
};
|
|
298
337
|
/**
|
|
299
|
-
* LFS mode configuration
|
|
338
|
+
* LFS mode configuration.
|
|
339
|
+
*
|
|
340
|
+
* - `'enabled'` (default): LFS behaves normally.
|
|
341
|
+
* - `'disabled'`: the `repo.lfs.*` / `repo.lfsExtra.*` helpers become no-ops.
|
|
342
|
+
* - object form: working-tree-populating operations (`checkout`, `switch`,
|
|
343
|
+
* `reset`, `merge`, `pull`, `rebase`, `restore`) run with
|
|
344
|
+
* `GIT_LFS_SKIP_SMUDGE=1` so Git leaves LFS pointer files in place instead of
|
|
345
|
+
* downloading their contents. The objects can be materialized later via the
|
|
346
|
+
* explicit `repo.lfs.pull()` / `repo.lfs.checkout()` helpers.
|
|
300
347
|
*/
|
|
301
348
|
type LfsMode = 'enabled' | 'disabled' | {
|
|
302
|
-
/** Skip smudge filter (don't download LFS files on checkout) */
|
|
349
|
+
/** Skip smudge filter (don't download LFS files on checkout). */
|
|
303
350
|
skipSmudge?: boolean;
|
|
304
|
-
/** Skip download
|
|
351
|
+
/** Skip download, keeping pointer files (also implies skip-smudge). */
|
|
305
352
|
skipDownload?: boolean;
|
|
306
353
|
};
|
|
307
354
|
/**
|
|
@@ -383,9 +430,12 @@ type GitOpenOptions = {
|
|
|
383
430
|
* Controls how the parent process environment is inherited by spawned Git commands.
|
|
384
431
|
*
|
|
385
432
|
* By default, only a curated allowlist of variables that Git needs to operate is
|
|
386
|
-
* inherited (environment variable traversal prevention).
|
|
387
|
-
*
|
|
388
|
-
*
|
|
433
|
+
* inherited (environment variable traversal prevention). See {@link EnvInheritance} for
|
|
434
|
+
* all supported forms:
|
|
435
|
+
* - `true` — inherit the full parent environment.
|
|
436
|
+
* - `string[]` — inherit the default allowlist plus the named variables.
|
|
437
|
+
* - `{ add?, remove? }` — adjust the default allowlist (e.g. drop `SSH_AUTH_SOCK`).
|
|
438
|
+
* - `(name) => boolean` — decide each variable individually.
|
|
389
439
|
*/
|
|
390
440
|
inheritEnv?: EnvInheritance;
|
|
391
441
|
/** Directories to prepend to PATH */
|
|
@@ -795,4 +845,4 @@ interface RuntimeAdapters {
|
|
|
795
845
|
*/
|
|
796
846
|
type AdapterFactory = () => RuntimeAdapters;
|
|
797
847
|
|
|
798
|
-
export { type AuditConfig as A, type
|
|
848
|
+
export { type AuditConfig as A, type AuditEventEnd as B, type Capabilities as C, DEFAULT_ENV_ALLOWLIST as D, type ExecAdapter as E, type FsAdapter as F, type GitErrorCategory as G, type AuditEvent as H, type TraceEvent as I, type LfsMode as L, type NonEmptyString as N, type OutputContract as O, type RuntimeAdapters as R, type SpawnOptions as S, type TailOptions as T, type StreamHandler as a, type SpawnResult as b, type SpawnHandle as c, type TailHandle as d, type ExecOpts as e, type RawResult as f, type GitProgress as g, type GitOpenOptions as h, type EnvInheritance as i, type ExecutionContext as j, GitError as k, type AdapterFactory as l, type EnvAllowlistAdjustment as m, type EnvInheritancePredicate as n, nonEmpty as o, isNonEmpty as p, type LfsProgress as q, resolveInheritedEnv as r, type GitErrorKind as s, GitArgumentError as t, type Runtime as u, type CommandSpec as v, type CredentialRequest as w, type Credential as x, type CredentialConfig as y, type AuditEventStart as z };
|
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
|
}
|
|
@@ -1408,7 +1444,7 @@ var BareRepoImpl = class {
|
|
|
1408
1444
|
*/
|
|
1409
1445
|
async push(opts) {
|
|
1410
1446
|
const args = ["push"];
|
|
1411
|
-
if (opts?.onProgress) {
|
|
1447
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
1412
1448
|
args.push("--progress");
|
|
1413
1449
|
}
|
|
1414
1450
|
if (opts?.force) {
|
|
@@ -2306,7 +2342,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2306
2342
|
*/
|
|
2307
2343
|
async push(opts) {
|
|
2308
2344
|
const args = ["push"];
|
|
2309
|
-
if (opts?.onProgress) {
|
|
2345
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2310
2346
|
args.push("--progress");
|
|
2311
2347
|
}
|
|
2312
2348
|
if (opts?.verbose) {
|
|
@@ -2411,6 +2447,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2411
2447
|
setLfsMode(mode) {
|
|
2412
2448
|
this._lfsMode = mode;
|
|
2413
2449
|
}
|
|
2450
|
+
/**
|
|
2451
|
+
* Per-command environment overrides derived from the configured LFS mode.
|
|
2452
|
+
*
|
|
2453
|
+
* When the repository was opened (or reconfigured) with an object-form LFS
|
|
2454
|
+
* mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
|
|
2455
|
+
* operations (checkout, switch, reset, merge, pull, rebase, restore) run with
|
|
2456
|
+
* `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
|
|
2457
|
+
* of downloading their contents during the implicit checkout.
|
|
2458
|
+
*
|
|
2459
|
+
* The objects can be materialized later via the explicit `repo.lfs.pull()` /
|
|
2460
|
+
* `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
|
|
2461
|
+
* not affected by `GIT_LFS_SKIP_SMUDGE`.
|
|
2462
|
+
*
|
|
2463
|
+
* Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
|
|
2464
|
+
* runner environment is left untouched.
|
|
2465
|
+
*/
|
|
2466
|
+
lfsModeEnv() {
|
|
2467
|
+
const mode = this._lfsMode;
|
|
2468
|
+
if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
|
|
2469
|
+
return { GIT_LFS_SKIP_SMUDGE: "1" };
|
|
2470
|
+
}
|
|
2471
|
+
return void 0;
|
|
2472
|
+
}
|
|
2414
2473
|
// ==========================================================================
|
|
2415
2474
|
// LFS Operations
|
|
2416
2475
|
// ==========================================================================
|
|
@@ -2433,7 +2492,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2433
2492
|
}
|
|
2434
2493
|
await this.runner.runOrThrow(this.context, args, {
|
|
2435
2494
|
signal: opts?.signal,
|
|
2436
|
-
onProgress: opts?.onProgress
|
|
2495
|
+
onProgress: opts?.onProgress,
|
|
2496
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2437
2497
|
});
|
|
2438
2498
|
}
|
|
2439
2499
|
async lfsPush(opts) {
|
|
@@ -2462,7 +2522,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2462
2522
|
}
|
|
2463
2523
|
await this.runner.runOrThrow(this.context, args, {
|
|
2464
2524
|
signal: opts?.signal,
|
|
2465
|
-
onProgress: opts?.onProgress
|
|
2525
|
+
onProgress: opts?.onProgress,
|
|
2526
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2466
2527
|
});
|
|
2467
2528
|
}
|
|
2468
2529
|
async lfsStatus(opts) {
|
|
@@ -2545,7 +2606,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2545
2606
|
const args = ["lfs", "push", remote, "--object-id", ...batch];
|
|
2546
2607
|
const result = await this.runner.run(this.context, args, {
|
|
2547
2608
|
signal: opts?.signal,
|
|
2548
|
-
onProgress: opts?.onProgress
|
|
2609
|
+
onProgress: opts?.onProgress,
|
|
2610
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2549
2611
|
});
|
|
2550
2612
|
if (result.exitCode === 0) {
|
|
2551
2613
|
uploadedCount += batch.length;
|
|
@@ -2622,7 +2684,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2622
2684
|
const args = ["lfs", "fetch", remote, "--", ...batch];
|
|
2623
2685
|
const result = await this.runner.run(this.context, args, {
|
|
2624
2686
|
signal: opts?.signal,
|
|
2625
|
-
onProgress: opts?.onProgress
|
|
2687
|
+
onProgress: opts?.onProgress,
|
|
2688
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2626
2689
|
});
|
|
2627
2690
|
if (result.exitCode === 0) {
|
|
2628
2691
|
downloadedCount += batch.length;
|
|
@@ -2687,7 +2750,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2687
2750
|
return;
|
|
2688
2751
|
}
|
|
2689
2752
|
const args = ["lfs", "fetch"];
|
|
2690
|
-
if (opts?.onProgress) {
|
|
2753
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2691
2754
|
args.push("--progress");
|
|
2692
2755
|
}
|
|
2693
2756
|
if (opts?.all) {
|
|
@@ -2720,7 +2783,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2720
2783
|
}
|
|
2721
2784
|
await this.runner.runOrThrow(this.context, args, {
|
|
2722
2785
|
signal: opts?.signal,
|
|
2723
|
-
onProgress: opts?.onProgress
|
|
2786
|
+
onProgress: opts?.onProgress,
|
|
2787
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2724
2788
|
});
|
|
2725
2789
|
}
|
|
2726
2790
|
async lfsInstall(opts) {
|
|
@@ -3482,7 +3546,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3482
3546
|
}
|
|
3483
3547
|
}
|
|
3484
3548
|
await this.runner.runOrThrow(this.context, args, {
|
|
3485
|
-
signal: opts?.signal
|
|
3549
|
+
signal: opts?.signal,
|
|
3550
|
+
env: this.lfsModeEnv()
|
|
3486
3551
|
});
|
|
3487
3552
|
}
|
|
3488
3553
|
// ==========================================================================
|
|
@@ -3839,7 +3904,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3839
3904
|
}
|
|
3840
3905
|
args.push(branch);
|
|
3841
3906
|
const result = await this.runner.run(this.context, args, {
|
|
3842
|
-
signal: opts?.signal
|
|
3907
|
+
signal: opts?.signal,
|
|
3908
|
+
env: this.lfsModeEnv()
|
|
3843
3909
|
});
|
|
3844
3910
|
if (result.exitCode !== 0) {
|
|
3845
3911
|
const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
|
|
@@ -3868,7 +3934,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3868
3934
|
// ==========================================================================
|
|
3869
3935
|
async pull(opts) {
|
|
3870
3936
|
const args = ["pull"];
|
|
3871
|
-
if (opts?.onProgress) {
|
|
3937
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
3872
3938
|
args.push("--progress");
|
|
3873
3939
|
}
|
|
3874
3940
|
if (opts?.rebase === true) {
|
|
@@ -4016,7 +4082,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4016
4082
|
}
|
|
4017
4083
|
await this.runner.runOrThrow(this.context, args, {
|
|
4018
4084
|
signal: opts?.signal,
|
|
4019
|
-
onProgress: opts?.onProgress
|
|
4085
|
+
onProgress: opts?.onProgress,
|
|
4086
|
+
onLfsProgress: opts?.onLfsProgress,
|
|
4087
|
+
env: this.lfsModeEnv()
|
|
4020
4088
|
});
|
|
4021
4089
|
}
|
|
4022
4090
|
// ==========================================================================
|
|
@@ -4046,7 +4114,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4046
4114
|
args.push(target);
|
|
4047
4115
|
}
|
|
4048
4116
|
await this.runner.runOrThrow(this.context, args, {
|
|
4049
|
-
signal: opts?.signal
|
|
4117
|
+
signal: opts?.signal,
|
|
4118
|
+
env: this.lfsModeEnv()
|
|
4050
4119
|
});
|
|
4051
4120
|
}
|
|
4052
4121
|
// ==========================================================================
|
|
@@ -4242,7 +4311,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4242
4311
|
args.push(opts.startPoint);
|
|
4243
4312
|
}
|
|
4244
4313
|
await this.runner.runOrThrow(this.context, args, {
|
|
4245
|
-
signal: opts?.signal
|
|
4314
|
+
signal: opts?.signal,
|
|
4315
|
+
env: this.lfsModeEnv()
|
|
4246
4316
|
});
|
|
4247
4317
|
}
|
|
4248
4318
|
// ==========================================================================
|
|
@@ -4669,7 +4739,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4669
4739
|
args.push(opts.upstream);
|
|
4670
4740
|
}
|
|
4671
4741
|
await this.runner.runOrThrow(this.context, args, {
|
|
4672
|
-
signal: opts?.signal
|
|
4742
|
+
signal: opts?.signal,
|
|
4743
|
+
env: this.lfsModeEnv()
|
|
4673
4744
|
});
|
|
4674
4745
|
}
|
|
4675
4746
|
// ==========================================================================
|
|
@@ -4727,7 +4798,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4727
4798
|
const pathList = Array.isArray(paths) ? paths : [paths];
|
|
4728
4799
|
args.push("--", ...pathList);
|
|
4729
4800
|
await this.runner.runOrThrow(this.context, args, {
|
|
4730
|
-
signal: opts?.signal
|
|
4801
|
+
signal: opts?.signal,
|
|
4802
|
+
env: this.lfsModeEnv()
|
|
4731
4803
|
});
|
|
4732
4804
|
}
|
|
4733
4805
|
// ==========================================================================
|
|
@@ -5740,7 +5812,7 @@ var GitImpl = class {
|
|
|
5740
5812
|
}
|
|
5741
5813
|
async clone(url, path, opts) {
|
|
5742
5814
|
const args = buildCloneArgs(opts);
|
|
5743
|
-
if (opts?.onProgress) {
|
|
5815
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
5744
5816
|
args.push("--progress");
|
|
5745
5817
|
}
|
|
5746
5818
|
args.push(url, path);
|