type-git 0.3.0-alpha.1 → 0.3.0-alpha.3
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 +14 -0
- package/dist/adapters/bun/index.cjs +2 -2
- 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 +2 -2
- package/dist/adapters/bun/index.js.map +1 -1
- package/dist/adapters/deno/index.cjs +35 -2
- 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 +35 -2
- package/dist/adapters/deno/index.js.map +1 -1
- package/dist/adapters/node/index.cjs +230 -61
- package/dist/adapters/node/index.cjs.map +1 -1
- package/dist/adapters/node/index.d.cts +57 -6
- package/dist/adapters/node/index.d.ts +57 -6
- package/dist/adapters/node/index.js +230 -61
- package/dist/adapters/node/index.js.map +1 -1
- package/dist/{adapters-Bpuvmw9y.d.cts → adapters-CZ8wj9Kr.d.cts} +60 -8
- package/dist/{adapters-Bpuvmw9y.d.ts → adapters-CZ8wj9Kr.d.ts} +60 -8
- package/dist/index.cjs +230 -61
- 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 +230 -61
- 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 { l as AdapterFactory, A as AuditConfig,
|
|
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-CZ8wj9Kr.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 { l as AdapterFactory, A as AuditConfig,
|
|
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-CZ8wj9Kr.js';
|
package/dist/index.js
CHANGED
|
@@ -533,6 +533,22 @@ var DEFAULT_ENV_ALLOWLIST = [
|
|
|
533
533
|
// SSH agent (required for Git-over-SSH authentication)
|
|
534
534
|
"SSH_AUTH_SOCK",
|
|
535
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",
|
|
536
552
|
// HTTP(S) proxy configuration (required for Git network operations behind a proxy)
|
|
537
553
|
"HTTP_PROXY",
|
|
538
554
|
"HTTPS_PROXY",
|
|
@@ -563,35 +579,52 @@ var DEFAULT_ENV_ALLOWLIST = [
|
|
|
563
579
|
"NUMBER_OF_PROCESSORS",
|
|
564
580
|
"PROCESSOR_ARCHITECTURE"
|
|
565
581
|
];
|
|
566
|
-
function
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
all[key] = value;
|
|
572
|
-
}
|
|
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;
|
|
573
587
|
}
|
|
574
|
-
return all;
|
|
575
588
|
}
|
|
589
|
+
return result;
|
|
590
|
+
}
|
|
591
|
+
function buildAllowlist(inheritEnv) {
|
|
576
592
|
const allow = new Set(inheritEnv === false ? [] : DEFAULT_ENV_ALLOWLIST);
|
|
577
593
|
if (Array.isArray(inheritEnv)) {
|
|
578
594
|
for (const name of inheritEnv) {
|
|
579
595
|
allow.add(name);
|
|
580
596
|
}
|
|
597
|
+
return { allow, remove: void 0 };
|
|
581
598
|
}
|
|
582
|
-
|
|
583
|
-
|
|
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
|
-
}
|
|
599
|
+
if (inheritEnv === false) {
|
|
600
|
+
return { allow, remove: void 0 };
|
|
593
601
|
}
|
|
594
|
-
|
|
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));
|
|
595
628
|
}
|
|
596
629
|
|
|
597
630
|
// src/runner/cli-runner.ts
|
|
@@ -776,8 +809,11 @@ var CliRunner = class _CliRunner {
|
|
|
776
809
|
*/
|
|
777
810
|
async run(context, args, opts) {
|
|
778
811
|
const argv = this.buildArgv(context, args);
|
|
779
|
-
const { signal, onProgress, onLfsProgress } = opts ?? {};
|
|
812
|
+
const { signal, onProgress, onLfsProgress, env: envOverride } = opts ?? {};
|
|
780
813
|
const env = this.buildEnv();
|
|
814
|
+
if (envOverride) {
|
|
815
|
+
Object.assign(env, envOverride);
|
|
816
|
+
}
|
|
781
817
|
if (onLfsProgress) {
|
|
782
818
|
env.GIT_LFS_FORCE_PROGRESS = "1";
|
|
783
819
|
}
|
|
@@ -797,6 +833,7 @@ var CliRunner = class _CliRunner {
|
|
|
797
833
|
result = await this.exec.spawn(
|
|
798
834
|
{
|
|
799
835
|
argv,
|
|
836
|
+
stdin: opts?.stdin,
|
|
800
837
|
env,
|
|
801
838
|
// The env above is already fully resolved (including any inherited variables),
|
|
802
839
|
// so the adapter must not merge the parent environment on top of it.
|
|
@@ -1345,7 +1382,7 @@ var BareRepoImpl = class {
|
|
|
1345
1382
|
*/
|
|
1346
1383
|
async push(opts) {
|
|
1347
1384
|
const args = ["push"];
|
|
1348
|
-
if (opts?.onProgress) {
|
|
1385
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
1349
1386
|
args.push("--progress");
|
|
1350
1387
|
}
|
|
1351
1388
|
if (opts?.force) {
|
|
@@ -1652,7 +1689,53 @@ var BareRepoImpl = class {
|
|
|
1652
1689
|
}
|
|
1653
1690
|
};
|
|
1654
1691
|
|
|
1692
|
+
// src/internal/concurrency.ts
|
|
1693
|
+
async function runWithConcurrency(items, run, options) {
|
|
1694
|
+
const { concurrency, warmupCount = 0 } = options;
|
|
1695
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
1696
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
1697
|
+
}
|
|
1698
|
+
if (!Number.isInteger(warmupCount) || warmupCount < 0) {
|
|
1699
|
+
throw new RangeError(`warmupCount must be a non-negative integer, got: ${warmupCount}`);
|
|
1700
|
+
}
|
|
1701
|
+
const results = new Array(items.length);
|
|
1702
|
+
let nextIndex = 0;
|
|
1703
|
+
let failed = false;
|
|
1704
|
+
let firstError;
|
|
1705
|
+
const runOne = async (index) => {
|
|
1706
|
+
try {
|
|
1707
|
+
const item = items[index];
|
|
1708
|
+
results[index] = await run(item, index);
|
|
1709
|
+
} catch (error) {
|
|
1710
|
+
if (!failed) {
|
|
1711
|
+
failed = true;
|
|
1712
|
+
firstError = error;
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
};
|
|
1716
|
+
const warmupEnd = Math.min(warmupCount, items.length);
|
|
1717
|
+
while (nextIndex < warmupEnd && !failed) {
|
|
1718
|
+
await runOne(nextIndex++);
|
|
1719
|
+
}
|
|
1720
|
+
if (!failed && nextIndex < items.length) {
|
|
1721
|
+
const worker = async () => {
|
|
1722
|
+
while (!failed && nextIndex < items.length) {
|
|
1723
|
+
await runOne(nextIndex++);
|
|
1724
|
+
}
|
|
1725
|
+
};
|
|
1726
|
+
const workerCount = Math.min(concurrency, items.length - nextIndex);
|
|
1727
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
1728
|
+
}
|
|
1729
|
+
if (failed) {
|
|
1730
|
+
throw firstError;
|
|
1731
|
+
}
|
|
1732
|
+
return results;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1655
1735
|
// src/impl/worktree-repo-impl.ts
|
|
1736
|
+
var PRE_UPLOAD_DEFAULT_BATCH_SIZE = 200;
|
|
1737
|
+
var PRE_UPLOAD_DEFAULT_CONCURRENCY = 4;
|
|
1738
|
+
var PRE_UPLOAD_WARMUP_BATCH_COUNT = 1;
|
|
1656
1739
|
var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
1657
1740
|
workdir;
|
|
1658
1741
|
runner;
|
|
@@ -2243,7 +2326,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2243
2326
|
*/
|
|
2244
2327
|
async push(opts) {
|
|
2245
2328
|
const args = ["push"];
|
|
2246
|
-
if (opts?.onProgress) {
|
|
2329
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2247
2330
|
args.push("--progress");
|
|
2248
2331
|
}
|
|
2249
2332
|
if (opts?.verbose) {
|
|
@@ -2348,6 +2431,29 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2348
2431
|
setLfsMode(mode) {
|
|
2349
2432
|
this._lfsMode = mode;
|
|
2350
2433
|
}
|
|
2434
|
+
/**
|
|
2435
|
+
* Per-command environment overrides derived from the configured LFS mode.
|
|
2436
|
+
*
|
|
2437
|
+
* When the repository was opened (or reconfigured) with an object-form LFS
|
|
2438
|
+
* mode requesting `skipSmudge` and/or `skipDownload`, working-tree-populating
|
|
2439
|
+
* operations (checkout, switch, reset, merge, pull, rebase, restore) run with
|
|
2440
|
+
* `GIT_LFS_SKIP_SMUDGE=1`. Git then leaves LFS pointer files in place instead
|
|
2441
|
+
* of downloading their contents during the implicit checkout.
|
|
2442
|
+
*
|
|
2443
|
+
* The objects can be materialized later via the explicit `repo.lfs.pull()` /
|
|
2444
|
+
* `repo.lfs.checkout()` helpers, which use dedicated git-lfs commands and are
|
|
2445
|
+
* not affected by `GIT_LFS_SKIP_SMUDGE`.
|
|
2446
|
+
*
|
|
2447
|
+
* Returns `undefined` for the `'enabled'` / `'disabled'` string modes so the
|
|
2448
|
+
* runner environment is left untouched.
|
|
2449
|
+
*/
|
|
2450
|
+
lfsModeEnv() {
|
|
2451
|
+
const mode = this._lfsMode;
|
|
2452
|
+
if (typeof mode === "object" && (mode.skipSmudge === true || mode.skipDownload === true)) {
|
|
2453
|
+
return { GIT_LFS_SKIP_SMUDGE: "1" };
|
|
2454
|
+
}
|
|
2455
|
+
return void 0;
|
|
2456
|
+
}
|
|
2351
2457
|
// ==========================================================================
|
|
2352
2458
|
// LFS Operations
|
|
2353
2459
|
// ==========================================================================
|
|
@@ -2370,36 +2476,41 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2370
2476
|
}
|
|
2371
2477
|
await this.runner.runOrThrow(this.context, args, {
|
|
2372
2478
|
signal: opts?.signal,
|
|
2373
|
-
onProgress: opts?.onProgress
|
|
2479
|
+
onProgress: opts?.onProgress,
|
|
2480
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2374
2481
|
});
|
|
2375
2482
|
}
|
|
2376
2483
|
async lfsPush(opts) {
|
|
2377
2484
|
if (this._lfsMode === "disabled") {
|
|
2378
2485
|
return;
|
|
2379
2486
|
}
|
|
2487
|
+
if (opts?.stdin && opts.objectId === void 0 && !opts.ref) {
|
|
2488
|
+
throw new TypeError("lfs.push with stdin requires objectId or ref");
|
|
2489
|
+
}
|
|
2380
2490
|
const args = ["lfs", "push"];
|
|
2381
2491
|
if (opts?.dryRun) {
|
|
2382
2492
|
args.push("--dry-run");
|
|
2383
2493
|
}
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
} else {
|
|
2390
|
-
args.push("--all");
|
|
2494
|
+
const oids = opts?.objectId !== void 0 ? Array.isArray(opts.objectId) ? opts.objectId : [opts.objectId] : void 0;
|
|
2495
|
+
if (oids?.length === 0 && !opts?.stdin) {
|
|
2496
|
+
throw new TypeError(
|
|
2497
|
+
"lfs.push with objectId requires at least one OID unless stdin is enabled"
|
|
2498
|
+
);
|
|
2391
2499
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2500
|
+
args.push(oids ? "--object-id" : "--all");
|
|
2501
|
+
args.push(opts?.remote ?? "origin");
|
|
2502
|
+
const values = oids ?? (opts?.ref ? [opts.ref] : []);
|
|
2503
|
+
if (opts?.stdin) {
|
|
2504
|
+
args.push("--stdin");
|
|
2394
2505
|
} else {
|
|
2395
|
-
args.push(
|
|
2396
|
-
}
|
|
2397
|
-
if (opts?.ref) {
|
|
2398
|
-
args.push(opts.ref);
|
|
2506
|
+
args.push(...values);
|
|
2399
2507
|
}
|
|
2400
2508
|
await this.runner.runOrThrow(this.context, args, {
|
|
2509
|
+
stdin: opts?.stdin ? values.length > 0 ? `${values.join("\n")}
|
|
2510
|
+
` : "" : void 0,
|
|
2401
2511
|
signal: opts?.signal,
|
|
2402
|
-
onProgress: opts?.onProgress
|
|
2512
|
+
onProgress: opts?.onProgress,
|
|
2513
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2403
2514
|
});
|
|
2404
2515
|
}
|
|
2405
2516
|
async lfsStatus(opts) {
|
|
@@ -2435,12 +2546,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2435
2546
|
* Pre-upload LFS objects before commit/push (2-phase commit pattern)
|
|
2436
2547
|
*
|
|
2437
2548
|
* This allows uploading LFS objects to the remote before creating a commit,
|
|
2438
|
-
* ensuring reliable large file handling. Objects are batched to
|
|
2439
|
-
*
|
|
2549
|
+
* ensuring reliable large file handling. Objects are batched to stay within
|
|
2550
|
+
* command-line length limits, and batches run with bounded concurrency to
|
|
2551
|
+
* overlap per-invocation fixed costs with other batches' transfers.
|
|
2552
|
+
*
|
|
2553
|
+
* Failure handling: once a batch fails, no new batch is started (in-flight
|
|
2554
|
+
* batches are awaited), and the objects of failed and unstarted batches are
|
|
2555
|
+
* reported in `skippedCount`. The first batch always runs alone before the
|
|
2556
|
+
* remaining batches widen to the concurrency limit, so a failure common to
|
|
2557
|
+
* all batches costs a single round-trip.
|
|
2440
2558
|
*
|
|
2441
2559
|
* Usage pattern:
|
|
2442
2560
|
* 1. Stage changes: git add
|
|
2443
|
-
* 2. Pre-upload LFS: await repo.
|
|
2561
|
+
* 2. Pre-upload LFS: await repo.lfsExtra.preUpload()
|
|
2444
2562
|
* 3. Commit: git commit
|
|
2445
2563
|
* 4. Push refs: git push (only refs, objects already uploaded)
|
|
2446
2564
|
*/
|
|
@@ -2449,7 +2567,14 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2449
2567
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2450
2568
|
}
|
|
2451
2569
|
const remote = opts?.remote ?? "origin";
|
|
2452
|
-
const batchSize = opts?.batchSize ??
|
|
2570
|
+
const batchSize = opts?.batchSize ?? PRE_UPLOAD_DEFAULT_BATCH_SIZE;
|
|
2571
|
+
const concurrency = opts?.concurrency ?? PRE_UPLOAD_DEFAULT_CONCURRENCY;
|
|
2572
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2573
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2574
|
+
}
|
|
2575
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
2576
|
+
throw new RangeError(`concurrency must be a positive integer, got: ${concurrency}`);
|
|
2577
|
+
}
|
|
2453
2578
|
let oids;
|
|
2454
2579
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2455
2580
|
oids = opts.oids;
|
|
@@ -2474,17 +2599,24 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2474
2599
|
if (oids.length === 0) {
|
|
2475
2600
|
return { uploadedCount: 0, uploadedBytes: 0, skippedCount: 0 };
|
|
2476
2601
|
}
|
|
2602
|
+
const batches = [];
|
|
2603
|
+
for (let i = 0; i < oids.length; i += batchSize) {
|
|
2604
|
+
batches.push(oids.slice(i, i + batchSize));
|
|
2605
|
+
}
|
|
2477
2606
|
let uploadedCount = 0;
|
|
2478
2607
|
let uploadedBytes = 0;
|
|
2479
2608
|
let skippedCount = 0;
|
|
2480
|
-
|
|
2481
|
-
|
|
2609
|
+
let attemptedCount = 0;
|
|
2610
|
+
const batchFailedStop = new Error("lfs pre-upload batch failed");
|
|
2611
|
+
const pushBatch = async (batch) => {
|
|
2482
2612
|
const args = ["lfs", "push", remote, "--object-id", ...batch];
|
|
2483
2613
|
const result = await this.runner.run(this.context, args, {
|
|
2484
2614
|
signal: opts?.signal,
|
|
2485
|
-
onProgress: opts?.onProgress
|
|
2615
|
+
onProgress: opts?.onProgress,
|
|
2616
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2486
2617
|
});
|
|
2487
|
-
|
|
2618
|
+
attemptedCount += batch.length;
|
|
2619
|
+
if (result.exitCode === 0 && !result.aborted) {
|
|
2488
2620
|
uploadedCount += batch.length;
|
|
2489
2621
|
const bytesMatch = result.stderr.match(
|
|
2490
2622
|
/Uploading LFS objects:.*?\((\d+(?:\.\d+)?)\s*([KMG]?B)/i
|
|
@@ -2504,7 +2636,19 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2504
2636
|
}
|
|
2505
2637
|
} else {
|
|
2506
2638
|
skippedCount += batch.length;
|
|
2639
|
+
throw batchFailedStop;
|
|
2507
2640
|
}
|
|
2641
|
+
};
|
|
2642
|
+
try {
|
|
2643
|
+
await runWithConcurrency(batches, pushBatch, {
|
|
2644
|
+
concurrency,
|
|
2645
|
+
warmupCount: PRE_UPLOAD_WARMUP_BATCH_COUNT
|
|
2646
|
+
});
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
if (error !== batchFailedStop) {
|
|
2649
|
+
throw error;
|
|
2650
|
+
}
|
|
2651
|
+
skippedCount += oids.length - attemptedCount;
|
|
2508
2652
|
}
|
|
2509
2653
|
return { uploadedCount, uploadedBytes, skippedCount };
|
|
2510
2654
|
}
|
|
@@ -2516,7 +2660,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2516
2660
|
*
|
|
2517
2661
|
* Usage pattern:
|
|
2518
2662
|
* 1. Fetch refs: git fetch
|
|
2519
|
-
* 2. Pre-download LFS: await repo.
|
|
2663
|
+
* 2. Pre-download LFS: await repo.lfsExtra.preDownload({ ref: 'origin/feature' })
|
|
2520
2664
|
* 3. Checkout: git checkout feature
|
|
2521
2665
|
*/
|
|
2522
2666
|
async lfsPreDownload(opts) {
|
|
@@ -2525,6 +2669,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2525
2669
|
}
|
|
2526
2670
|
const remote = opts?.remote ?? "origin";
|
|
2527
2671
|
const batchSize = opts?.batchSize ?? 50;
|
|
2672
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
2673
|
+
throw new RangeError(`batchSize must be a positive integer, got: ${batchSize}`);
|
|
2674
|
+
}
|
|
2528
2675
|
let oids;
|
|
2529
2676
|
if (opts?.oids && opts.oids.length > 0) {
|
|
2530
2677
|
oids = opts.oids;
|
|
@@ -2559,7 +2706,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2559
2706
|
const args = ["lfs", "fetch", remote, "--", ...batch];
|
|
2560
2707
|
const result = await this.runner.run(this.context, args, {
|
|
2561
2708
|
signal: opts?.signal,
|
|
2562
|
-
onProgress: opts?.onProgress
|
|
2709
|
+
onProgress: opts?.onProgress,
|
|
2710
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2563
2711
|
});
|
|
2564
2712
|
if (result.exitCode === 0) {
|
|
2565
2713
|
downloadedCount += batch.length;
|
|
@@ -2624,7 +2772,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2624
2772
|
return;
|
|
2625
2773
|
}
|
|
2626
2774
|
const args = ["lfs", "fetch"];
|
|
2627
|
-
if (opts?.onProgress) {
|
|
2775
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
2628
2776
|
args.push("--progress");
|
|
2629
2777
|
}
|
|
2630
2778
|
if (opts?.all) {
|
|
@@ -2657,7 +2805,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
2657
2805
|
}
|
|
2658
2806
|
await this.runner.runOrThrow(this.context, args, {
|
|
2659
2807
|
signal: opts?.signal,
|
|
2660
|
-
onProgress: opts?.onProgress
|
|
2808
|
+
onProgress: opts?.onProgress,
|
|
2809
|
+
onLfsProgress: opts?.onLfsProgress
|
|
2661
2810
|
});
|
|
2662
2811
|
}
|
|
2663
2812
|
async lfsInstall(opts) {
|
|
@@ -3419,7 +3568,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3419
3568
|
}
|
|
3420
3569
|
}
|
|
3421
3570
|
await this.runner.runOrThrow(this.context, args, {
|
|
3422
|
-
signal: opts?.signal
|
|
3571
|
+
signal: opts?.signal,
|
|
3572
|
+
env: this.lfsModeEnv()
|
|
3423
3573
|
});
|
|
3424
3574
|
}
|
|
3425
3575
|
// ==========================================================================
|
|
@@ -3776,7 +3926,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3776
3926
|
}
|
|
3777
3927
|
args.push(branch);
|
|
3778
3928
|
const result = await this.runner.run(this.context, args, {
|
|
3779
|
-
signal: opts?.signal
|
|
3929
|
+
signal: opts?.signal,
|
|
3930
|
+
env: this.lfsModeEnv()
|
|
3780
3931
|
});
|
|
3781
3932
|
if (result.exitCode !== 0) {
|
|
3782
3933
|
const statusResult = await this.runner.runOrThrow(this.context, ["status", "--porcelain"], {
|
|
@@ -3805,7 +3956,7 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3805
3956
|
// ==========================================================================
|
|
3806
3957
|
async pull(opts) {
|
|
3807
3958
|
const args = ["pull"];
|
|
3808
|
-
if (opts?.onProgress) {
|
|
3959
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
3809
3960
|
args.push("--progress");
|
|
3810
3961
|
}
|
|
3811
3962
|
if (opts?.rebase === true) {
|
|
@@ -3953,7 +4104,9 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3953
4104
|
}
|
|
3954
4105
|
await this.runner.runOrThrow(this.context, args, {
|
|
3955
4106
|
signal: opts?.signal,
|
|
3956
|
-
onProgress: opts?.onProgress
|
|
4107
|
+
onProgress: opts?.onProgress,
|
|
4108
|
+
onLfsProgress: opts?.onLfsProgress,
|
|
4109
|
+
env: this.lfsModeEnv()
|
|
3957
4110
|
});
|
|
3958
4111
|
}
|
|
3959
4112
|
// ==========================================================================
|
|
@@ -3983,7 +4136,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
3983
4136
|
args.push(target);
|
|
3984
4137
|
}
|
|
3985
4138
|
await this.runner.runOrThrow(this.context, args, {
|
|
3986
|
-
signal: opts?.signal
|
|
4139
|
+
signal: opts?.signal,
|
|
4140
|
+
env: this.lfsModeEnv()
|
|
3987
4141
|
});
|
|
3988
4142
|
}
|
|
3989
4143
|
// ==========================================================================
|
|
@@ -4179,7 +4333,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4179
4333
|
args.push(opts.startPoint);
|
|
4180
4334
|
}
|
|
4181
4335
|
await this.runner.runOrThrow(this.context, args, {
|
|
4182
|
-
signal: opts?.signal
|
|
4336
|
+
signal: opts?.signal,
|
|
4337
|
+
env: this.lfsModeEnv()
|
|
4183
4338
|
});
|
|
4184
4339
|
}
|
|
4185
4340
|
// ==========================================================================
|
|
@@ -4606,7 +4761,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4606
4761
|
args.push(opts.upstream);
|
|
4607
4762
|
}
|
|
4608
4763
|
await this.runner.runOrThrow(this.context, args, {
|
|
4609
|
-
signal: opts?.signal
|
|
4764
|
+
signal: opts?.signal,
|
|
4765
|
+
env: this.lfsModeEnv()
|
|
4610
4766
|
});
|
|
4611
4767
|
}
|
|
4612
4768
|
// ==========================================================================
|
|
@@ -4664,7 +4820,8 @@ var WorktreeRepoImpl = class _WorktreeRepoImpl {
|
|
|
4664
4820
|
const pathList = Array.isArray(paths) ? paths : [paths];
|
|
4665
4821
|
args.push("--", ...pathList);
|
|
4666
4822
|
await this.runner.runOrThrow(this.context, args, {
|
|
4667
|
-
signal: opts?.signal
|
|
4823
|
+
signal: opts?.signal,
|
|
4824
|
+
env: this.lfsModeEnv()
|
|
4668
4825
|
});
|
|
4669
4826
|
}
|
|
4670
4827
|
// ==========================================================================
|
|
@@ -5677,7 +5834,7 @@ var GitImpl = class {
|
|
|
5677
5834
|
}
|
|
5678
5835
|
async clone(url, path, opts) {
|
|
5679
5836
|
const args = buildCloneArgs(opts);
|
|
5680
|
-
if (opts?.onProgress) {
|
|
5837
|
+
if (opts?.onProgress || opts?.onLfsProgress) {
|
|
5681
5838
|
args.push("--progress");
|
|
5682
5839
|
}
|
|
5683
5840
|
args.push(url, path);
|
|
@@ -6061,7 +6218,7 @@ var NodeExecAdapter = class {
|
|
|
6061
6218
|
const child = spawn(command, args, {
|
|
6062
6219
|
cwd,
|
|
6063
6220
|
env: resolveChildEnv(env, inheritEnv),
|
|
6064
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6221
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6065
6222
|
});
|
|
6066
6223
|
let stdout = "";
|
|
6067
6224
|
let stderr = "";
|
|
@@ -6089,6 +6246,12 @@ var NodeExecAdapter = class {
|
|
|
6089
6246
|
stderr += text;
|
|
6090
6247
|
handlers?.onStderr?.(text);
|
|
6091
6248
|
});
|
|
6249
|
+
child.stdin?.on("error", (error) => {
|
|
6250
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6251
|
+
reject(error);
|
|
6252
|
+
}
|
|
6253
|
+
});
|
|
6254
|
+
child.stdin?.end(options.stdin);
|
|
6092
6255
|
child.on("error", (error) => {
|
|
6093
6256
|
signal?.removeEventListener("abort", abortHandler);
|
|
6094
6257
|
reject(error);
|
|
@@ -6117,7 +6280,7 @@ var NodeExecAdapter = class {
|
|
|
6117
6280
|
const child = spawn(command, args, {
|
|
6118
6281
|
cwd,
|
|
6119
6282
|
env: resolveChildEnv(env, inheritEnv),
|
|
6120
|
-
stdio: ["ignore", "pipe", "pipe"]
|
|
6283
|
+
stdio: [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
|
|
6121
6284
|
});
|
|
6122
6285
|
let aborted = false;
|
|
6123
6286
|
let exitSignal;
|
|
@@ -6142,6 +6305,12 @@ var NodeExecAdapter = class {
|
|
|
6142
6305
|
child.stderr?.on("data", (chunk) => {
|
|
6143
6306
|
stderr += chunk.toString("utf8");
|
|
6144
6307
|
});
|
|
6308
|
+
child.stdin?.on("error", (error) => {
|
|
6309
|
+
if (error.code !== "EPIPE" && error.code !== "EOF") {
|
|
6310
|
+
reject(error);
|
|
6311
|
+
}
|
|
6312
|
+
});
|
|
6313
|
+
child.stdin?.end(options.stdin);
|
|
6145
6314
|
child.on("error", (error) => {
|
|
6146
6315
|
signal?.removeEventListener("abort", abortHandler);
|
|
6147
6316
|
reject(error);
|