@paraharness/git 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +68 -2
- package/dist/builders/create-git-candidate-comparison-tools.d.ts +14 -0
- package/dist/builders/create-git-candidate-comparison-tools.d.ts.map +1 -0
- package/dist/builders/create-git-candidate-comparison-tools.js +42 -0
- package/dist/builders/create-git-candidate-comparison-tools.js.map +1 -0
- package/dist/builders/create-git-commit-and-push-builder.d.ts +18 -0
- package/dist/builders/create-git-commit-and-push-builder.d.ts.map +1 -0
- package/dist/builders/create-git-commit-and-push-builder.js +60 -0
- package/dist/builders/create-git-commit-and-push-builder.js.map +1 -0
- package/dist/builders/create-git-cow-worktree-builder.d.ts +16 -0
- package/dist/builders/create-git-cow-worktree-builder.d.ts.map +1 -0
- package/dist/builders/create-git-cow-worktree-builder.js +72 -0
- package/dist/builders/create-git-cow-worktree-builder.js.map +1 -0
- package/dist/builders/create-git-discard-branch-builder.d.ts +13 -0
- package/dist/builders/create-git-discard-branch-builder.d.ts.map +1 -0
- package/dist/builders/create-git-discard-branch-builder.js +22 -0
- package/dist/builders/create-git-discard-branch-builder.js.map +1 -0
- package/dist/builders/create-git-keep-worktree-builder.d.ts +13 -0
- package/dist/builders/create-git-keep-worktree-builder.d.ts.map +1 -0
- package/dist/builders/create-git-keep-worktree-builder.js +22 -0
- package/dist/builders/create-git-keep-worktree-builder.js.map +1 -0
- package/dist/builders/create-git-merge-queue-builder.d.ts +19 -0
- package/dist/builders/create-git-merge-queue-builder.d.ts.map +1 -0
- package/dist/builders/create-git-merge-queue-builder.js +59 -0
- package/dist/builders/create-git-merge-queue-builder.js.map +1 -0
- package/dist/builders/create-git-patch-equivalence-builder.d.ts +13 -0
- package/dist/builders/create-git-patch-equivalence-builder.d.ts.map +1 -0
- package/dist/builders/create-git-patch-equivalence-builder.js +32 -0
- package/dist/builders/create-git-patch-equivalence-builder.js.map +1 -0
- package/dist/builders/create-git-public-surface-cross-tester-builder.d.ts +14 -0
- package/dist/builders/create-git-public-surface-cross-tester-builder.d.ts.map +1 -0
- package/dist/builders/create-git-public-surface-cross-tester-builder.js +38 -0
- package/dist/builders/create-git-public-surface-cross-tester-builder.js.map +1 -0
- package/dist/builders/create-git-ref-reader-tools.d.ts +14 -0
- package/dist/builders/create-git-ref-reader-tools.d.ts.map +1 -0
- package/dist/builders/create-git-ref-reader-tools.js +42 -0
- package/dist/builders/create-git-ref-reader-tools.js.map +1 -0
- package/dist/builders/create-git-reset-worktree-builder.d.ts +13 -0
- package/dist/builders/create-git-reset-worktree-builder.d.ts.map +1 -0
- package/dist/builders/create-git-reset-worktree-builder.js +22 -0
- package/dist/builders/create-git-reset-worktree-builder.js.map +1 -0
- package/dist/builders/create-git-snapshot-and-reset-builder.d.ts +13 -0
- package/dist/builders/create-git-snapshot-and-reset-builder.d.ts.map +1 -0
- package/dist/builders/create-git-snapshot-and-reset-builder.js +23 -0
- package/dist/builders/create-git-snapshot-and-reset-builder.js.map +1 -0
- package/dist/builders/git-commit-and-push-builder.d.ts +44 -0
- package/dist/builders/git-commit-and-push-builder.d.ts.map +1 -0
- package/dist/builders/git-commit-and-push-builder.js +2 -0
- package/dist/builders/git-commit-and-push-builder.js.map +1 -0
- package/dist/builders/git-commit-and-push-options.d.ts +22 -0
- package/dist/builders/git-commit-and-push-options.d.ts.map +1 -0
- package/dist/builders/git-commit-and-push-options.js +2 -0
- package/dist/builders/git-commit-and-push-options.js.map +1 -0
- package/dist/builders/git-cow-worktree-builder.d.ts +64 -0
- package/dist/builders/git-cow-worktree-builder.d.ts.map +1 -0
- package/dist/builders/git-cow-worktree-builder.js +2 -0
- package/dist/builders/git-cow-worktree-builder.js.map +1 -0
- package/dist/builders/git-cow-worktree-options.d.ts +42 -0
- package/dist/builders/git-cow-worktree-options.d.ts.map +1 -0
- package/dist/builders/git-cow-worktree-options.js +2 -0
- package/dist/builders/git-cow-worktree-options.js.map +1 -0
- package/dist/builders/git-merge-queue-builder.d.ts +37 -0
- package/dist/builders/git-merge-queue-builder.d.ts.map +1 -0
- package/dist/builders/git-merge-queue-builder.js +2 -0
- package/dist/builders/git-merge-queue-builder.js.map +1 -0
- package/dist/builders/git-merge-queue-options.d.ts +23 -0
- package/dist/builders/git-merge-queue-options.d.ts.map +1 -0
- package/dist/builders/git-merge-queue-options.js +2 -0
- package/dist/builders/git-merge-queue-options.js.map +1 -0
- package/dist/builders/git-namespace-contract.d.ts +142 -0
- package/dist/builders/git-namespace-contract.d.ts.map +1 -0
- package/dist/builders/git-namespace-contract.js +2 -0
- package/dist/builders/git-namespace-contract.js.map +1 -0
- package/dist/builders/git-namespace.d.ts +6 -0
- package/dist/builders/git-namespace.d.ts.map +1 -0
- package/dist/builders/git-namespace.js +32 -0
- package/dist/builders/git-namespace.js.map +1 -0
- package/dist/builders/git-public-surface-cross-tester-options.d.ts +16 -0
- package/dist/builders/git-public-surface-cross-tester-options.d.ts.map +1 -0
- package/dist/builders/git-public-surface-cross-tester-options.js +2 -0
- package/dist/builders/git-public-surface-cross-tester-options.js.map +1 -0
- package/dist/builders/git-reconcile-strategy-options.d.ts +16 -0
- package/dist/builders/git-reconcile-strategy-options.d.ts.map +1 -0
- package/dist/builders/git-reconcile-strategy-options.js +2 -0
- package/dist/builders/git-reconcile-strategy-options.js.map +1 -0
- package/dist/builders/internal/build-git-cow-worktree-node.d.ts +35 -0
- package/dist/builders/internal/build-git-cow-worktree-node.d.ts.map +1 -0
- package/dist/builders/internal/build-git-cow-worktree-node.js +77 -0
- package/dist/builders/internal/build-git-cow-worktree-node.js.map +1 -0
- package/dist/executors/create-git-executors.d.ts +12 -0
- package/dist/executors/create-git-executors.d.ts.map +1 -0
- package/dist/executors/create-git-executors.js +43 -0
- package/dist/executors/create-git-executors.js.map +1 -0
- package/dist/executors/git-checkpoint-payload.d.ts +44 -0
- package/dist/executors/git-checkpoint-payload.d.ts.map +1 -0
- package/dist/executors/git-checkpoint-payload.js +2 -0
- package/dist/executors/git-checkpoint-payload.js.map +1 -0
- package/dist/executors/git-commit-and-merge-steps.d.ts +33 -0
- package/dist/executors/git-commit-and-merge-steps.d.ts.map +1 -0
- package/dist/executors/git-commit-and-merge-steps.js +52 -0
- package/dist/executors/git-commit-and-merge-steps.js.map +1 -0
- package/dist/executors/git-cow-worktree-scope.d.ts +201 -0
- package/dist/executors/git-cow-worktree-scope.d.ts.map +1 -0
- package/dist/executors/git-cow-worktree-scope.js +260 -0
- package/dist/executors/git-cow-worktree-scope.js.map +1 -0
- package/dist/executors/git-cross-verifiers-and-tools.d.ts +42 -0
- package/dist/executors/git-cross-verifiers-and-tools.d.ts.map +1 -0
- package/dist/executors/git-cross-verifiers-and-tools.js +112 -0
- package/dist/executors/git-cross-verifiers-and-tools.js.map +1 -0
- package/dist/executors/git-executors.constants.d.ts +4 -0
- package/dist/executors/git-executors.constants.d.ts.map +1 -0
- package/dist/executors/git-executors.constants.js +4 -0
- package/dist/executors/git-executors.constants.js.map +1 -0
- package/dist/executors/git-hooks-and-checks.d.ts +51 -0
- package/dist/executors/git-hooks-and-checks.d.ts.map +1 -0
- package/dist/executors/git-hooks-and-checks.js +139 -0
- package/dist/executors/git-hooks-and-checks.js.map +1 -0
- package/dist/executors/internal/checkpoint-restore-steps.d.ts +50 -0
- package/dist/executors/internal/checkpoint-restore-steps.d.ts.map +1 -0
- package/dist/executors/internal/checkpoint-restore-steps.js +184 -0
- package/dist/executors/internal/checkpoint-restore-steps.js.map +1 -0
- package/dist/executors/internal/checkpoint-staging-and-integrity.d.ts +51 -0
- package/dist/executors/internal/checkpoint-staging-and-integrity.d.ts.map +1 -0
- package/dist/executors/internal/checkpoint-staging-and-integrity.js +192 -0
- package/dist/executors/internal/checkpoint-staging-and-integrity.js.map +1 -0
- package/dist/executors/internal/compute-worktree-status-options.d.ts +15 -0
- package/dist/executors/internal/compute-worktree-status-options.d.ts.map +1 -0
- package/dist/executors/internal/compute-worktree-status-options.js +2 -0
- package/dist/executors/internal/compute-worktree-status-options.js.map +1 -0
- package/dist/executors/internal/cow-worktree-hydrator.d.ts +51 -0
- package/dist/executors/internal/cow-worktree-hydrator.d.ts.map +1 -0
- package/dist/executors/internal/cow-worktree-hydrator.js +174 -0
- package/dist/executors/internal/cow-worktree-hydrator.js.map +1 -0
- package/dist/executors/internal/file-digest-and-globs.d.ts +58 -0
- package/dist/executors/internal/file-digest-and-globs.d.ts.map +1 -0
- package/dist/executors/internal/file-digest-and-globs.js +188 -0
- package/dist/executors/internal/file-digest-and-globs.js.map +1 -0
- package/dist/executors/internal/git-checkpoint-diff-effects.d.ts +16 -0
- package/dist/executors/internal/git-checkpoint-diff-effects.d.ts.map +1 -0
- package/dist/executors/internal/git-checkpoint-diff-effects.js +38 -0
- package/dist/executors/internal/git-checkpoint-diff-effects.js.map +1 -0
- package/dist/executors/internal/git-checkpoint-restore.d.ts +14 -0
- package/dist/executors/internal/git-checkpoint-restore.d.ts.map +1 -0
- package/dist/executors/internal/git-checkpoint-restore.js +37 -0
- package/dist/executors/internal/git-checkpoint-restore.js.map +1 -0
- package/dist/executors/internal/git-checkpoint-serialize.d.ts +13 -0
- package/dist/executors/internal/git-checkpoint-serialize.d.ts.map +1 -0
- package/dist/executors/internal/git-checkpoint-serialize.js +48 -0
- package/dist/executors/internal/git-checkpoint-serialize.js.map +1 -0
- package/dist/executors/internal/git-checkpoint-status-map.d.ts +14 -0
- package/dist/executors/internal/git-checkpoint-status-map.d.ts.map +1 -0
- package/dist/executors/internal/git-checkpoint-status-map.js +27 -0
- package/dist/executors/internal/git-checkpoint-status-map.js.map +1 -0
- package/dist/executors/internal/git-cli-command-options.d.ts +21 -0
- package/dist/executors/internal/git-cli-command-options.d.ts.map +1 -0
- package/dist/executors/internal/git-cli-command-options.js +2 -0
- package/dist/executors/internal/git-cli-command-options.js.map +1 -0
- package/dist/executors/internal/git-cli-command-result.d.ts +16 -0
- package/dist/executors/internal/git-cli-command-result.d.ts.map +1 -0
- package/dist/executors/internal/git-cli-command-result.js +2 -0
- package/dist/executors/internal/git-cli-command-result.js.map +1 -0
- package/dist/executors/internal/git-cli-runner.d.ts +73 -0
- package/dist/executors/internal/git-cli-runner.d.ts.map +1 -0
- package/dist/executors/internal/git-cli-runner.js +157 -0
- package/dist/executors/internal/git-cli-runner.js.map +1 -0
- package/dist/executors/internal/git-cross-test-import-scanner.d.ts +68 -0
- package/dist/executors/internal/git-cross-test-import-scanner.d.ts.map +1 -0
- package/dist/executors/internal/git-cross-test-import-scanner.js +226 -0
- package/dist/executors/internal/git-cross-test-import-scanner.js.map +1 -0
- package/dist/executors/internal/git-executor.constants.d.ts +29 -0
- package/dist/executors/internal/git-executor.constants.d.ts.map +1 -0
- package/dist/executors/internal/git-executor.constants.js +40 -0
- package/dist/executors/internal/git-executor.constants.js.map +1 -0
- package/dist/executors/internal/git-merge-train-bisect.d.ts +51 -0
- package/dist/executors/internal/git-merge-train-bisect.d.ts.map +1 -0
- package/dist/executors/internal/git-merge-train-bisect.js +152 -0
- package/dist/executors/internal/git-merge-train-bisect.js.map +1 -0
- package/dist/executors/internal/git-tool-dispatchers.d.ts +26 -0
- package/dist/executors/internal/git-tool-dispatchers.d.ts.map +1 -0
- package/dist/executors/internal/git-tool-dispatchers.js +174 -0
- package/dist/executors/internal/git-tool-dispatchers.js.map +1 -0
- package/dist/executors/internal/git-worktree-acquire-root.d.ts +22 -0
- package/dist/executors/internal/git-worktree-acquire-root.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-acquire-root.js +67 -0
- package/dist/executors/internal/git-worktree-acquire-root.js.map +1 -0
- package/dist/executors/internal/git-worktree-commit-child.d.ts +26 -0
- package/dist/executors/internal/git-worktree-commit-child.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-commit-child.js +88 -0
- package/dist/executors/internal/git-worktree-commit-child.js.map +1 -0
- package/dist/executors/internal/git-worktree-flush-and-prune.d.ts +43 -0
- package/dist/executors/internal/git-worktree-flush-and-prune.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-flush-and-prune.js +169 -0
- package/dist/executors/internal/git-worktree-flush-and-prune.js.map +1 -0
- package/dist/executors/internal/git-worktree-fork-and-release.d.ts +37 -0
- package/dist/executors/internal/git-worktree-fork-and-release.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-fork-and-release.js +159 -0
- package/dist/executors/internal/git-worktree-fork-and-release.js.map +1 -0
- package/dist/executors/internal/git-worktree-materialize-merge.d.ts +51 -0
- package/dist/executors/internal/git-worktree-materialize-merge.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-materialize-merge.js +161 -0
- package/dist/executors/internal/git-worktree-materialize-merge.js.map +1 -0
- package/dist/executors/internal/git-worktree-reattach.d.ts +57 -0
- package/dist/executors/internal/git-worktree-reattach.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-reattach.js +324 -0
- package/dist/executors/internal/git-worktree-reattach.js.map +1 -0
- package/dist/executors/internal/git-worktree-sync-child-and-root.d.ts +26 -0
- package/dist/executors/internal/git-worktree-sync-child-and-root.d.ts.map +1 -0
- package/dist/executors/internal/git-worktree-sync-child-and-root.js +82 -0
- package/dist/executors/internal/git-worktree-sync-child-and-root.js.map +1 -0
- package/dist/executors/internal/host-repository-head-state.d.ts +10 -0
- package/dist/executors/internal/host-repository-head-state.d.ts.map +1 -0
- package/dist/executors/internal/host-repository-head-state.js +2 -0
- package/dist/executors/internal/host-repository-head-state.js.map +1 -0
- package/dist/executors/internal/merge-train-candidate.d.ts +14 -0
- package/dist/executors/internal/merge-train-candidate.d.ts.map +1 -0
- package/dist/executors/internal/merge-train-candidate.js +2 -0
- package/dist/executors/internal/merge-train-candidate.js.map +1 -0
- package/dist/executors/internal/merge-train-chain-entry.d.ts +13 -0
- package/dist/executors/internal/merge-train-chain-entry.d.ts.map +1 -0
- package/dist/executors/internal/merge-train-chain-entry.js +2 -0
- package/dist/executors/internal/merge-train-chain-entry.js.map +1 -0
- package/dist/executors/internal/merge-train-result.d.ts +19 -0
- package/dist/executors/internal/merge-train-result.d.ts.map +1 -0
- package/dist/executors/internal/merge-train-result.js +2 -0
- package/dist/executors/internal/merge-train-result.js.map +1 -0
- package/dist/executors/internal/merge-train-runner.d.ts +16 -0
- package/dist/executors/internal/merge-train-runner.d.ts.map +1 -0
- package/dist/executors/internal/merge-train-runner.js +141 -0
- package/dist/executors/internal/merge-train-runner.js.map +1 -0
- package/dist/executors/internal/merge-tree-materializer-params.d.ts +19 -0
- package/dist/executors/internal/merge-tree-materializer-params.d.ts.map +1 -0
- package/dist/executors/internal/merge-tree-materializer-params.js +2 -0
- package/dist/executors/internal/merge-tree-materializer-params.js.map +1 -0
- package/dist/executors/internal/parent-fast-forward.d.ts +47 -0
- package/dist/executors/internal/parent-fast-forward.d.ts.map +1 -0
- package/dist/executors/internal/parent-fast-forward.js +138 -0
- package/dist/executors/internal/parent-fast-forward.js.map +1 -0
- package/dist/executors/internal/porcelain-v2-parser.d.ts +49 -0
- package/dist/executors/internal/porcelain-v2-parser.d.ts.map +1 -0
- package/dist/executors/internal/porcelain-v2-parser.js +165 -0
- package/dist/executors/internal/porcelain-v2-parser.js.map +1 -0
- package/dist/executors/internal/resolve-effective-base-branch.d.ts +13 -0
- package/dist/executors/internal/resolve-effective-base-branch.d.ts.map +1 -0
- package/dist/executors/internal/resolve-effective-base-branch.js +38 -0
- package/dist/executors/internal/resolve-effective-base-branch.js.map +1 -0
- package/dist/executors/internal/squash-rebase-and-push.d.ts +14 -0
- package/dist/executors/internal/squash-rebase-and-push.d.ts.map +1 -0
- package/dist/executors/internal/squash-rebase-and-push.js +192 -0
- package/dist/executors/internal/squash-rebase-and-push.js.map +1 -0
- package/dist/executors/internal/staged-checkpoint-tree-result.d.ts +13 -0
- package/dist/executors/internal/staged-checkpoint-tree-result.d.ts.map +1 -0
- package/dist/executors/internal/staged-checkpoint-tree-result.js +2 -0
- package/dist/executors/internal/staged-checkpoint-tree-result.js.map +1 -0
- package/dist/executors/internal/stateless-merge-tree-result.d.ts +12 -0
- package/dist/executors/internal/stateless-merge-tree-result.d.ts.map +1 -0
- package/dist/executors/internal/stateless-merge-tree-result.js +2 -0
- package/dist/executors/internal/stateless-merge-tree-result.js.map +1 -0
- package/dist/executors/internal/synthesized-working-tree-commit.d.ts +10 -0
- package/dist/executors/internal/synthesized-working-tree-commit.d.ts.map +1 -0
- package/dist/executors/internal/synthesized-working-tree-commit.js +2 -0
- package/dist/executors/internal/synthesized-working-tree-commit.js.map +1 -0
- package/dist/executors/internal/worktree-integrity-verdict.d.ts +10 -0
- package/dist/executors/internal/worktree-integrity-verdict.d.ts.map +1 -0
- package/dist/executors/internal/worktree-integrity-verdict.js +2 -0
- package/dist/executors/internal/worktree-integrity-verdict.js.map +1 -0
- package/dist/executors/internal/worktree-status-snapshot.d.ts +17 -0
- package/dist/executors/internal/worktree-status-snapshot.d.ts.map +1 -0
- package/dist/executors/internal/worktree-status-snapshot.js +2 -0
- package/dist/executors/internal/worktree-status-snapshot.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/git-receipts.schema.d.ts +174 -0
- package/dist/schemas/git-receipts.schema.d.ts.map +1 -0
- package/dist/schemas/git-receipts.schema.js +123 -0
- package/dist/schemas/git-receipts.schema.js.map +1 -0
- package/package.json +71 -3
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { constants as fsConstants } from 'node:fs';
|
|
3
|
+
import { chmod, copyFile, lstat, mkdir, readdir, readFile, readlink, rm, symlink, } from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import picomatch from 'picomatch';
|
|
6
|
+
import { COMPILED_EXCLUDE_MATCHER_CACHE, IMPLICIT_REPO_EXCLUDE_GLOBS, } from './git-executor.constants.js';
|
|
7
|
+
/**
|
|
8
|
+
* Computes the `${mode}:${sha256}` digest for a worktree path using `lstat(2)` and `readlink(2)` / `readFile(2)`.
|
|
9
|
+
*
|
|
10
|
+
* Returns `'DELETED'` when the path does not exist on disk (`ENOENT`), and hashes symlink target strings
|
|
11
|
+
* without dereferencing broken or external symlinks.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} fullPath - Absolute filesystem path to inspect.
|
|
14
|
+
*
|
|
15
|
+
* @returns {Promise<string>} Formatted `${mode}:${sha256}` digest string or `'DELETED'`.
|
|
16
|
+
*/
|
|
17
|
+
export async function computePathModeAndSha256(fullPath) {
|
|
18
|
+
try {
|
|
19
|
+
const stat = await lstat(fullPath);
|
|
20
|
+
const hash = createHash('sha256');
|
|
21
|
+
if (stat.isSymbolicLink()) {
|
|
22
|
+
const target = await readlink(fullPath, 'utf8');
|
|
23
|
+
hash.update(target, 'utf8');
|
|
24
|
+
return `120000:${hash.digest('hex')}`;
|
|
25
|
+
}
|
|
26
|
+
if (stat.isDirectory())
|
|
27
|
+
return '040000:directory';
|
|
28
|
+
const content = await readFile(fullPath);
|
|
29
|
+
hash.update(content);
|
|
30
|
+
const gitMode = (stat.mode & 0o111) !== 0 ? '100755' : '100644';
|
|
31
|
+
return `${gitMode}:${hash.digest('hex')}`;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return 'DELETED';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Compiles a reusable predicate testing whether a repository-relative path should be excluded from checkpoints/clones.
|
|
39
|
+
*
|
|
40
|
+
* Always returns `false` for `.gitignore` and `**\/.gitignore` so gitignore tampering is never masked.
|
|
41
|
+
*
|
|
42
|
+
* @param {readonly string[] | undefined} excludeGlobs - Configured glob patterns to exclude.
|
|
43
|
+
*
|
|
44
|
+
* @returns {(relPath: string) => boolean} Synchronous path exclusion predicate.
|
|
45
|
+
*/
|
|
46
|
+
export function compileWorktreeExcludeMatcher(excludeGlobs) {
|
|
47
|
+
const allGlobs = [...IMPLICIT_REPO_EXCLUDE_GLOBS, ...(excludeGlobs ?? [])];
|
|
48
|
+
const cacheKey = allGlobs.join('\0');
|
|
49
|
+
const cached = COMPILED_EXCLUDE_MATCHER_CACHE.get(cacheKey);
|
|
50
|
+
if (cached !== undefined) {
|
|
51
|
+
return cached;
|
|
52
|
+
}
|
|
53
|
+
const matchers = [];
|
|
54
|
+
for (const pattern of allGlobs) {
|
|
55
|
+
matchers.push(picomatch(pattern, { dot: true }));
|
|
56
|
+
}
|
|
57
|
+
const compiled = (relPath) => {
|
|
58
|
+
const normalized = relPath.replace(/\\/g, '/').replace(/\/+$/, '');
|
|
59
|
+
if (normalized === '.gitignore' || normalized.endsWith('/.gitignore'))
|
|
60
|
+
return false;
|
|
61
|
+
for (const isMatch of matchers) {
|
|
62
|
+
if (isMatch(normalized))
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
COMPILED_EXCLUDE_MATCHER_CACHE.set(cacheKey, compiled);
|
|
68
|
+
return compiled;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks whether a relative directory path inside `node_modules` is a transient bundler or test-runner cache directory.
|
|
72
|
+
*
|
|
73
|
+
* Matches both top-level and nested `.cache`, `.vite`, and `.vitest` directories.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} relDir - Forward-slash relative directory path inside `node_modules`.
|
|
76
|
+
*
|
|
77
|
+
* @returns {boolean} `true` when `relDir` is a transient `.cache`, `.vite`, or `.vitest` directory.
|
|
78
|
+
*/
|
|
79
|
+
function isTransientNodeModulesCacheDir(relDir) {
|
|
80
|
+
return (relDir === '.cache' ||
|
|
81
|
+
relDir === '.vite' ||
|
|
82
|
+
relDir === '.vitest' ||
|
|
83
|
+
relDir.endsWith('/.cache') ||
|
|
84
|
+
relDir.endsWith('/.vite') ||
|
|
85
|
+
relDir.endsWith('/.vitest'));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Computes a structural SHA-256 digest of `<worktreePath>/node_modules`.
|
|
89
|
+
*
|
|
90
|
+
* Walks regular files and symlinks inside `node_modules` (excluding top-level and nested `.cache`, `.vite`, and `.vitest`)
|
|
91
|
+
* so `diffEffects` and `restoreCheckpoint` can detect `node_modules` tampering without performing backup I/O.
|
|
92
|
+
*
|
|
93
|
+
* @param {string} worktreePath - Worktree root directory path.
|
|
94
|
+
*
|
|
95
|
+
* @returns {Promise<string>} Hex SHA-256 digest of the `node_modules` tree, or `'ABSENT'` when not present.
|
|
96
|
+
*/
|
|
97
|
+
export async function computeNodeModulesDigest(worktreePath) {
|
|
98
|
+
const nmRoot = path.join(worktreePath, 'node_modules');
|
|
99
|
+
const rootStat = await lstat(nmRoot).catch(() => null);
|
|
100
|
+
if (rootStat === null)
|
|
101
|
+
return 'ABSENT';
|
|
102
|
+
const hash = createHash('sha256');
|
|
103
|
+
const stack = [''];
|
|
104
|
+
while (stack.length > 0) {
|
|
105
|
+
const relDir = stack.pop() ?? '';
|
|
106
|
+
if (isTransientNodeModulesCacheDir(relDir))
|
|
107
|
+
continue;
|
|
108
|
+
const entries = await readdir(path.join(nmRoot, relDir), { withFileTypes: true });
|
|
109
|
+
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
110
|
+
for (const entry of entries) {
|
|
111
|
+
const childRel = relDir.length === 0 ? entry.name : `${relDir}/${entry.name}`;
|
|
112
|
+
if (entry.isDirectory())
|
|
113
|
+
stack.push(childRel);
|
|
114
|
+
else {
|
|
115
|
+
const digest = await computePathModeAndSha256(path.join(nmRoot, childRel));
|
|
116
|
+
hash.update(`${childRel}:${digest}\n`, 'utf8');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return hash.digest('hex');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Mirrors `<worktreePath>/node_modules` into `<backupRootDir>/<digest>` via Copy-on-Write if not already backed up.
|
|
124
|
+
*
|
|
125
|
+
* Skips transient `.cache`, `.vite`, and `.vitest` subdirectories and short-circuits when `digest === 'ABSENT'`
|
|
126
|
+
* or `<backupRootDir>/<digest>` already exists on disk.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} worktreePath - Worktree root directory path.
|
|
129
|
+
* @param {string} digest - Precomputed structural SHA-256 digest of `node_modules`.
|
|
130
|
+
* @param {string} backupRootDir - `<gitdir>/harness-ckpt-nm` backup root directory.
|
|
131
|
+
*
|
|
132
|
+
* @returns {Promise<void>} Resolves once the content-addressed backup directory is populated.
|
|
133
|
+
*/
|
|
134
|
+
export async function snapshotNodeModulesForCheckpoint(worktreePath, digest, backupRootDir) {
|
|
135
|
+
if (digest === 'ABSENT')
|
|
136
|
+
return;
|
|
137
|
+
const nmRoot = path.join(worktreePath, 'node_modules');
|
|
138
|
+
const digestBackupDir = path.join(backupRootDir, digest);
|
|
139
|
+
const exists = await lstat(digestBackupDir).then(() => true, () => false);
|
|
140
|
+
if (exists)
|
|
141
|
+
return;
|
|
142
|
+
const stack = [''];
|
|
143
|
+
while (stack.length > 0) {
|
|
144
|
+
const relDir = stack.pop() ?? '';
|
|
145
|
+
if (isTransientNodeModulesCacheDir(relDir))
|
|
146
|
+
continue;
|
|
147
|
+
const entries = await readdir(path.join(nmRoot, relDir), { withFileTypes: true });
|
|
148
|
+
for (const entry of entries) {
|
|
149
|
+
const childRel = relDir.length === 0 ? entry.name : `${relDir}/${entry.name}`;
|
|
150
|
+
if (entry.isDirectory())
|
|
151
|
+
stack.push(childRel);
|
|
152
|
+
else {
|
|
153
|
+
await copyFileCowOrValue(path.join(nmRoot, childRel), path.join(digestBackupDir, childRel));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Copies a single file or symbolic link using Copy-on-Write (`COPYFILE_FICLONE`) when supported, falling back to value copy.
|
|
160
|
+
*
|
|
161
|
+
* Preserves symbolic links via `readlink` + `symlink` and applies POSIX file permission bits (`mode`) for regular files.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} srcPath - Source file or symlink path.
|
|
164
|
+
* @param {string} destPath - Destination file or symlink path.
|
|
165
|
+
* @param {number} [mode] - Optional POSIX permission mode to apply.
|
|
166
|
+
*
|
|
167
|
+
* @returns {Promise<void>} Resolves once the file or symlink is copied.
|
|
168
|
+
*/
|
|
169
|
+
export async function copyFileCowOrValue(srcPath, destPath, mode) {
|
|
170
|
+
await mkdir(path.dirname(destPath), { recursive: true });
|
|
171
|
+
const stat = await lstat(srcPath);
|
|
172
|
+
if (stat.isSymbolicLink()) {
|
|
173
|
+
const linkTarget = await readlink(srcPath, 'utf8');
|
|
174
|
+
await rm(destPath, { force: true });
|
|
175
|
+
await symlink(linkTarget, destPath);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
await copyFile(srcPath, destPath, fsConstants.COPYFILE_FICLONE);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
await copyFile(srcPath, destPath);
|
|
183
|
+
}
|
|
184
|
+
if (mode !== undefined) {
|
|
185
|
+
await chmod(destPath, mode & 0o777);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=file-digest-and-globs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-digest-and-globs.js","sourceRoot":"","sources":["../../../src/executors/internal/file-digest-and-globs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EACL,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,OAAO,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,GAC5B,MAAM,6BAA6B,CAAC;AAErC;;;;;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,CAAC;gBACJ,MAAM,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC9F,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,QAAgB,EAChB,IAAa;IAEb,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QAC1B,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACpC,MAAM,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACpC,OAAO;IACT,CAAC;IACD,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IAClE,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IACD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GitCowWorktreeNode, GitWorktreeHandle, ToolEffect } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Verifies worktree-local `.git` and `node_modules` integrity and diffs post-flight file effects against `fromCheckpointJson`.
|
|
4
|
+
*
|
|
5
|
+
* Immediately invokes `gitCheckpointRestore` and throws a non-leasable error if `.git` or `node_modules` was tampered with.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} fromCheckpointJson - Serialized `GitCheckpointPayload` string.
|
|
8
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle.
|
|
9
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy configuration.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<readonly ToolEffect[]>} Synthesized `FsToolEffect` list for the symmetric status difference.
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} If worktree-local `.git` metadata or `node_modules` was tampered with.
|
|
14
|
+
*/
|
|
15
|
+
export declare function gitCheckpointDiffEffects(fromCheckpointJson: string, handle: GitWorktreeHandle, policy?: GitCowWorktreeNode['checkpointPolicy']): Promise<readonly ToolEffect[]>;
|
|
16
|
+
//# sourceMappingURL=git-checkpoint-diff-effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-diff-effects.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-diff-effects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAa3B;;;;;;;;;;;;GAYG;AACH,wBAAsB,wBAAwB,CAC5C,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,GAC9C,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CA8BhC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { computeSymmetricStatusDiff, verifyWorktreeLocalGitIntegrity, } from './checkpoint-staging-and-integrity.js';
|
|
2
|
+
import { gitCheckpointRestore } from './git-checkpoint-restore.js';
|
|
3
|
+
import { gitCheckpointStatusMap } from './git-checkpoint-status-map.js';
|
|
4
|
+
import { buildFsDiffToolEffects, hasGitignoreChanged, } from './porcelain-v2-parser.js';
|
|
5
|
+
/**
|
|
6
|
+
* Verifies worktree-local `.git` and `node_modules` integrity and diffs post-flight file effects against `fromCheckpointJson`.
|
|
7
|
+
*
|
|
8
|
+
* Immediately invokes `gitCheckpointRestore` and throws a non-leasable error if `.git` or `node_modules` was tampered with.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} fromCheckpointJson - Serialized `GitCheckpointPayload` string.
|
|
11
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle.
|
|
12
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy configuration.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Promise<readonly ToolEffect[]>} Synthesized `FsToolEffect` list for the symmetric status difference.
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} If worktree-local `.git` metadata or `node_modules` was tampered with.
|
|
17
|
+
*/
|
|
18
|
+
export async function gitCheckpointDiffEffects(fromCheckpointJson, handle, policy) {
|
|
19
|
+
const fromCheckpoint = JSON.parse(fromCheckpointJson);
|
|
20
|
+
const integrity = await verifyWorktreeLocalGitIntegrity(handle, fromCheckpoint);
|
|
21
|
+
if (!integrity.intact) {
|
|
22
|
+
await gitCheckpointRestore(handle, fromCheckpointJson, policy);
|
|
23
|
+
throw new Error(`Non-leasable worktree integrity violation in '${handle.worktreePath}': ${integrity.reason ?? 'tampered metadata'}`);
|
|
24
|
+
}
|
|
25
|
+
const initialSnap = await gitCheckpointStatusMap(handle.worktreePath, {
|
|
26
|
+
excludeGlobs: policy?.excludeGlobs,
|
|
27
|
+
});
|
|
28
|
+
const finalSnap = hasGitignoreChanged(fromCheckpoint.statusMap, initialSnap.statusMap)
|
|
29
|
+
? await gitCheckpointStatusMap(handle.worktreePath, {
|
|
30
|
+
excludeGlobs: policy?.excludeGlobs,
|
|
31
|
+
includeMatchingIgnored: true,
|
|
32
|
+
baselineIgnoredPaths: new Set(fromCheckpoint.ignoredPaths),
|
|
33
|
+
})
|
|
34
|
+
: initialSnap;
|
|
35
|
+
const symDiff = computeSymmetricStatusDiff(fromCheckpoint.statusMap, finalSnap.statusMap);
|
|
36
|
+
return buildFsDiffToolEffects(handle, symDiff);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=git-checkpoint-diff-effects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-diff-effects.js","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-diff-effects.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,kBAA0B,EAC1B,MAAyB,EACzB,MAA+C;IAE/C,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAyB,CAAC;IAC9E,MAAM,SAAS,GAAG,MAAM,+BAA+B,CACrD,MAAM,EACN,cAAc,CACf,CAAC;IACF,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACtB,MAAM,oBAAoB,CAAC,MAAM,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;QAC/D,MAAM,IAAI,KAAK,CACb,iDAAiD,MAAM,CAAC,YAAY,MAAM,SAAS,CAAC,MAAM,IAAI,mBAAmB,EAAE,CACpH,CAAC;IACJ,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE;QACpE,YAAY,EAAE,MAAM,EAAE,YAAY;KACnC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,mBAAmB,CACnC,cAAc,CAAC,SAAS,EACxB,WAAW,CAAC,SAAS,CACtB;QACC,CAAC,CAAC,MAAM,sBAAsB,CAAC,MAAM,CAAC,YAAY,EAAE;YAChD,YAAY,EAAE,MAAM,EAAE,YAAY;YAClC,sBAAsB,EAAE,IAAI;YAC5B,oBAAoB,EAAE,IAAI,GAAG,CAAC,cAAc,CAAC,YAAY,CAAC;SAC3D,CAAC;QACJ,CAAC,CAAC,WAAW,CAAC;IAChB,MAAM,OAAO,GAAG,0BAA0B,CACxC,cAAc,CAAC,SAAS,EACxB,SAAS,CAAC,SAAS,CACpB,CAAC;IACF,OAAO,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GitCowWorktreeNode, GitWorktreeHandle } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Restores `handle` to `fromCheckpointJson` using the deterministic 4-step Git-Index restoration protocol.
|
|
4
|
+
*
|
|
5
|
+
* Restores `.git` metadata and `.gitignore` rules, unlinks added/colliding paths, checks out `treeSha`, and restores spilled blobs.
|
|
6
|
+
*
|
|
7
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle to restore.
|
|
8
|
+
* @param {string} fromCheckpointJson - Serialized `GitCheckpointPayload` string.
|
|
9
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy configuration.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<void>} Resolves once the worktree matches `fromCheckpointJson` bit-for-bit.
|
|
12
|
+
*/
|
|
13
|
+
export declare function gitCheckpointRestore(handle: GitWorktreeHandle, fromCheckpointJson: string, policy?: GitCowWorktreeNode['checkpointPolicy']): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=git-checkpoint-restore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-restore.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-restore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAe/E;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,iBAAiB,EACzB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,GAC9C,OAAO,CAAC,IAAI,CAAC,CAkCf"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { checkoutCheckpointTreeAndRestoreIndex, restoreGitdirMetadataAndGitignores, restoreOversizedUntrackedBlobs, unlinkAddedAndDirectoryCollisions, } from './checkpoint-restore-steps.js';
|
|
2
|
+
import { computeSymmetricStatusDiff, listTreePaths, verifyWorktreeLocalGitIntegrity, } from './checkpoint-staging-and-integrity.js';
|
|
3
|
+
import { gitCheckpointStatusMap } from './git-checkpoint-status-map.js';
|
|
4
|
+
/**
|
|
5
|
+
* Restores `handle` to `fromCheckpointJson` using the deterministic 4-step Git-Index restoration protocol.
|
|
6
|
+
*
|
|
7
|
+
* Restores `.git` metadata and `.gitignore` rules, unlinks added/colliding paths, checks out `treeSha`, and restores spilled blobs.
|
|
8
|
+
*
|
|
9
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle to restore.
|
|
10
|
+
* @param {string} fromCheckpointJson - Serialized `GitCheckpointPayload` string.
|
|
11
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy configuration.
|
|
12
|
+
*
|
|
13
|
+
* @returns {Promise<void>} Resolves once the worktree matches `fromCheckpointJson` bit-for-bit.
|
|
14
|
+
*/
|
|
15
|
+
export async function gitCheckpointRestore(handle, fromCheckpointJson, policy) {
|
|
16
|
+
const fromCheckpoint = JSON.parse(fromCheckpointJson);
|
|
17
|
+
const integrity = await verifyWorktreeLocalGitIntegrity(handle, fromCheckpoint);
|
|
18
|
+
const treePaths = await listTreePaths(handle.worktreePath, fromCheckpoint.treeSha);
|
|
19
|
+
await restoreGitdirMetadataAndGitignores(handle, fromCheckpoint, treePaths);
|
|
20
|
+
const currentSnap = await gitCheckpointStatusMap(handle.worktreePath, {
|
|
21
|
+
excludeGlobs: policy?.excludeGlobs,
|
|
22
|
+
includeMatchingIgnored: true,
|
|
23
|
+
baselineIgnoredPaths: new Set(fromCheckpoint.ignoredPaths),
|
|
24
|
+
});
|
|
25
|
+
const symDiff = computeSymmetricStatusDiff(fromCheckpoint.statusMap, currentSnap.statusMap);
|
|
26
|
+
const preservedPaths = new Set([
|
|
27
|
+
...treePaths,
|
|
28
|
+
...Object.keys(fromCheckpoint.oversizedUntrackedBlobs),
|
|
29
|
+
]);
|
|
30
|
+
await unlinkAddedAndDirectoryCollisions(handle, symDiff, preservedPaths);
|
|
31
|
+
const pathsToCheckout = !integrity.intact
|
|
32
|
+
? 'ALL'
|
|
33
|
+
: symDiff.filter((relPath) => treePaths.has(relPath));
|
|
34
|
+
await checkoutCheckpointTreeAndRestoreIndex(handle, fromCheckpoint, pathsToCheckout);
|
|
35
|
+
await restoreOversizedUntrackedBlobs(handle, fromCheckpoint);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=git-checkpoint-restore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-restore.js","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-restore.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qCAAqC,EACrC,kCAAkC,EAClC,8BAA8B,EAC9B,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,0BAA0B,EAC1B,aAAa,EACb,+BAA+B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAyB,EACzB,kBAA0B,EAC1B,M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ness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Serializes a non-mutating Git-Index checkpoint for `handle` without advancing `HEAD` or touching `<gitdir>/index`.
|
|
4
|
+
*
|
|
5
|
+
* Captures worktree-local `.git` metadata, `statusMap`, temporary-index `treeSha`, and any spilled oversized untracked blobs.
|
|
6
|
+
*
|
|
7
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle to snapshot.
|
|
8
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy from `GitCowWorktreeNode`.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<string>} JSON-serialized `GitCheckpointPayload` string.
|
|
11
|
+
*/
|
|
12
|
+
export declare function gitCheckpointSerialize(handle: GitWorktreeHandle, policy?: GitCowWorktreeNode['checkpointPolicy']): Promise<string>;
|
|
13
|
+
//# sourceMappingURL=git-checkpoint-serialize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-serialize.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-serialize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAW/E;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,iBAAiB,EACzB,MAAM,CAAC,EAAE,kBAAkB,CAAC,kBAAkB,CAAC,GAC9C,OAAO,CAAC,MAAM,CAAC,CA4CjB"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { stageCheckpointTreeAndOversizedBlobs } from './checkpoint-staging-and-integrity.js';
|
|
4
|
+
import { computeNodeModulesDigest, snapshotNodeModulesForCheckpoint, } from './file-digest-and-globs.js';
|
|
5
|
+
import { gitCheckpointStatusMap } from './git-checkpoint-status-map.js';
|
|
6
|
+
import { readHarnessMeta, runGitCommand } from './git-cli-runner.js';
|
|
7
|
+
import { DEFAULT_MAX_UNTRACKED_FILE_SIZE_BYTES } from './git-executor.constants.js';
|
|
8
|
+
/**
|
|
9
|
+
* Serializes a non-mutating Git-Index checkpoint for `handle` without advancing `HEAD` or touching `<gitdir>/index`.
|
|
10
|
+
*
|
|
11
|
+
* Captures worktree-local `.git` metadata, `statusMap`, temporary-index `treeSha`, and any spilled oversized untracked blobs.
|
|
12
|
+
*
|
|
13
|
+
* @param {GitWorktreeHandle} handle - Active worktree handle to snapshot.
|
|
14
|
+
* @param {GitCowWorktreeNode['checkpointPolicy']} [policy] - Optional checkpoint policy from `GitCowWorktreeNode`.
|
|
15
|
+
*
|
|
16
|
+
* @returns {Promise<string>} JSON-serialized `GitCheckpointPayload` string.
|
|
17
|
+
*/
|
|
18
|
+
export async function gitCheckpointSerialize(handle, policy) {
|
|
19
|
+
const headRawContent = await readFile(path.join(handle.gitDirPath, 'HEAD'), 'utf8');
|
|
20
|
+
const indexTreeResult = await runGitCommand({
|
|
21
|
+
cwd: handle.worktreePath,
|
|
22
|
+
args: ['write-tree'],
|
|
23
|
+
});
|
|
24
|
+
const infoExcludeContent = await readFile(path.join(handle.gitDirPath, 'info', 'exclude'), 'utf8').catch(() => null);
|
|
25
|
+
const meta = await readHarnessMeta(handle.gitDirPath);
|
|
26
|
+
const snapshot = await gitCheckpointStatusMap(handle.worktreePath, {
|
|
27
|
+
excludeGlobs: policy?.excludeGlobs,
|
|
28
|
+
includeMatchingIgnored: true,
|
|
29
|
+
});
|
|
30
|
+
const maxBytes = policy?.maxUntrackedFileSizeBytes ?? DEFAULT_MAX_UNTRACKED_FILE_SIZE_BYTES;
|
|
31
|
+
const staged = await stageCheckpointTreeAndOversizedBlobs(handle, snapshot, maxBytes);
|
|
32
|
+
const nodeModulesDigest = await computeNodeModulesDigest(handle.worktreePath);
|
|
33
|
+
await snapshotNodeModulesForCheckpoint(handle.worktreePath, nodeModulesDigest, path.join(handle.gitDirPath, 'harness-ckpt-nm'));
|
|
34
|
+
const payload = Object.freeze({
|
|
35
|
+
headSha: staged.headSha,
|
|
36
|
+
headRawContent,
|
|
37
|
+
indexTreeSha: indexTreeResult.stdout.trim(),
|
|
38
|
+
infoExcludeContent,
|
|
39
|
+
meta,
|
|
40
|
+
statusMap: snapshot.statusMap,
|
|
41
|
+
ignoredPaths: snapshot.ignoredPaths,
|
|
42
|
+
nodeModulesDigest,
|
|
43
|
+
treeSha: staged.treeSha,
|
|
44
|
+
oversizedUntrackedBlobs: staged.oversizedUntrackedBlobs,
|
|
45
|
+
});
|
|
46
|
+
return JSON.stringify(payload);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=git-checkpoint-serialize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-serialize.js","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,oCAAoC,EAAE,MAAM,uCAAuC,CAAC;AAC7F,OAAO,EACL,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AAEpF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,MAAyB,EACzB,MAA+C;IAE/C,MAAM,cAAc,GAAG,MAAM,QAAQ,CACnC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,EACpC,MAAM,CACP,CAAC;IACF,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC;QAC1C,GAAG,EAAE,MAAM,CAAC,YAAY;QACxB,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CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComputeWorktreeStatusOptions } from './compute-worktree-status-options.js';
|
|
2
|
+
import type { WorktreeStatusSnapshot } from './worktree-status-snapshot.js';
|
|
3
|
+
/**
|
|
4
|
+
* Computes the porcelain v2 status snapshot for `worktreePath` (`git status --porcelain=v2 -z --no-renames --untracked-files=all`).
|
|
5
|
+
*
|
|
6
|
+
* Optionally enables `--ignored=matching` when scanning for files hidden behind a `.gitignore` mutation.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} worktreePath - Worktree directory path to scan.
|
|
9
|
+
* @param {ComputeWorktreeStatusOptions} [options] - Optional exclusion globs and ignored-matching flags.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<WorktreeStatusSnapshot>} Structured status map, untracked set, deleted set, and ignored paths.
|
|
12
|
+
*/
|
|
13
|
+
export declare function gitCheckpointStatusMap(worktreePath: string, options?: ComputeWorktreeStatusOptions): Promise<WorktreeStatusSnapshot>;
|
|
14
|
+
//# sourceMappingURL=git-checkpoint-status-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-status-map.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-status-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAGzF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAE5E;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CAC1C,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,4BAA4B,GACrC,OAAO,CAAC,sBAAsB,CAAC,CAajC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { runGitCommand } from './git-cli-runner.js';
|
|
2
|
+
import { parsePorcelainV2Records } from './porcelain-v2-parser.js';
|
|
3
|
+
/**
|
|
4
|
+
* Computes the porcelain v2 status snapshot for `worktreePath` (`git status --porcelain=v2 -z --no-renames --untracked-files=all`).
|
|
5
|
+
*
|
|
6
|
+
* Optionally enables `--ignored=matching` when scanning for files hidden behind a `.gitignore` mutation.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} worktreePath - Worktree directory path to scan.
|
|
9
|
+
* @param {ComputeWorktreeStatusOptions} [options] - Optional exclusion globs and ignored-matching flags.
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<WorktreeStatusSnapshot>} Structured status map, untracked set, deleted set, and ignored paths.
|
|
12
|
+
*/
|
|
13
|
+
export async function gitCheckpointStatusMap(worktreePath, options) {
|
|
14
|
+
const args = [
|
|
15
|
+
'status',
|
|
16
|
+
'--porcelain=v2',
|
|
17
|
+
'-z',
|
|
18
|
+
'--no-renames',
|
|
19
|
+
'--untracked-files=all',
|
|
20
|
+
];
|
|
21
|
+
if (options?.includeMatchingIgnored) {
|
|
22
|
+
args.push('--ignored=matching');
|
|
23
|
+
}
|
|
24
|
+
const statusResult = await runGitCommand({ cwd: worktreePath, args });
|
|
25
|
+
return parsePorcelainV2Records(worktreePath, statusResult.stdout, options);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=git-checkpoint-status-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-checkpoint-status-map.js","sourceRoot":"","sources":["../../../src/executors/internal/git-checkpoint-status-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAGnE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,YAAoB,EACpB,OAAsC;IAEtC,MAAM,IAAI,GAAG;QACX,QAAQ;QACR,gBAAgB;QAChB,IAAI;QACJ,cAAc;QACd,uBAAuB;KACxB,CAAC;IACF,IAAI,OAAO,EAAE,sBAAsB,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,uBAAuB,CAAC,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution options passed to `runGitCommand`.
|
|
3
|
+
*
|
|
4
|
+
* Configures the working directory, `git` CLI argument vector, optional `stdin` payload,
|
|
5
|
+
* isolated environment variables, and whether non-zero exit codes should be returned instead of thrown.
|
|
6
|
+
*/
|
|
7
|
+
export interface GitCliCommandOptions {
|
|
8
|
+
/** Working directory in which `git` is spawned. */
|
|
9
|
+
readonly cwd: string;
|
|
10
|
+
/** Argument vector passed to the `git` binary. */
|
|
11
|
+
readonly args: readonly string[];
|
|
12
|
+
/** Optional additional environment variables merged into the isolated worktree environment. */
|
|
13
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
14
|
+
/** Optional standard input buffer or UTF-8 string piped to the subprocess. */
|
|
15
|
+
readonly stdin?: string | Buffer;
|
|
16
|
+
/** When `true`, resolves `GitCliCommandResult` on non-zero exit codes instead of throwing. */
|
|
17
|
+
readonly allowNonZeroExit?: boolean;
|
|
18
|
+
/** Optional `AbortSignal` to terminate the git subprocess early. */
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=git-cli-command-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli-command-options.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-cli-command-options.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,+FAA+F;IAC/F,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC5D,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli-command-options.js","sourceRoot":"","sources":["../../../src/executors/internal/git-cli-command-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result returned by `runGitCommand` after executing a `git` CLI subprocess.
|
|
3
|
+
*
|
|
4
|
+
* Contains the exit code, decoded UTF-8 `stdout` and `stderr` strings, and raw `stdoutBuffer` bytes.
|
|
5
|
+
*/
|
|
6
|
+
export interface GitCliCommandResult {
|
|
7
|
+
/** Numeric subprocess exit code (`0` on success). */
|
|
8
|
+
readonly exitCode: number;
|
|
9
|
+
/** UTF-8 decoded standard output. */
|
|
10
|
+
readonly stdout: string;
|
|
11
|
+
/** UTF-8 decoded standard error. */
|
|
12
|
+
readonly stderr: string;
|
|
13
|
+
/** Raw standard output buffer for NUL-delimited (`-z`) binary/path parsing. */
|
|
14
|
+
readonly stdoutBuffer: Buffer;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=git-cli-command-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli-command-result.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-cli-command-result.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oCAAoC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli-command-result.js","sourceRoot":"","sources":["../../../src/executors/internal/git-cli-command-result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { GitWorktreeHandle } from '@paraharness/core';
|
|
2
|
+
import { type HarnessMetaRecord } from '../../schemas/git-receipts.schema.js';
|
|
3
|
+
import type { GitCliCommandOptions } from './git-cli-command-options.js';
|
|
4
|
+
import type { GitCliCommandResult } from './git-cli-command-result.js';
|
|
5
|
+
/**
|
|
6
|
+
* Constructs the isolated environment map for git and subprocess invocations inside a worktree.
|
|
7
|
+
*
|
|
8
|
+
* Sets `GIT_CEILING_DIRECTORIES=<dirname(worktreePath)>`, `GIT_CONFIG_NOSYSTEM=1`, `GIT_OPTIONAL_LOCKS=0`,
|
|
9
|
+
* disables GPG signing, and forces `core.hooksPath=/dev/null` per `SPEC.md` §4.4.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} worktreePath - Worktree directory path.
|
|
12
|
+
* @param {Readonly<Record<string, string | undefined>>} [extraEnv] - Optional overrides merged on top.
|
|
13
|
+
*
|
|
14
|
+
* @returns {Readonly<Record<string, string>>} Frozen environment map for subprocess execution.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildIsolatedWorktreeGitEnv(worktreePath: string, extraEnv?: Readonly<Record<string, string | undefined>>): Readonly<Record<string, string>>;
|
|
17
|
+
/**
|
|
18
|
+
* Spawns a `git` CLI command inside `options.cwd` with isolated worktree environment settings.
|
|
19
|
+
*
|
|
20
|
+
* Pipes optional `stdin`, captures `stdoutBuffer` and `stderr`, cleans up `AbortSignal` listeners,
|
|
21
|
+
* and throws an actionable diagnostic `Error` when `exitCode !== 0` unless `allowNonZeroExit` is set.
|
|
22
|
+
*
|
|
23
|
+
* @param {GitCliCommandOptions} options - Command execution options.
|
|
24
|
+
*
|
|
25
|
+
* @returns {Promise<GitCliCommandResult>} Resolved exit code, decoded output strings, and raw stdout buffer.
|
|
26
|
+
*
|
|
27
|
+
* @throws {Error} If the `git` process exits non-zero and `allowNonZeroExit` is not `true`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function runGitCommand(options: GitCliCommandOptions): Promise<GitCliCommandResult>;
|
|
30
|
+
/**
|
|
31
|
+
* Reads and validates `<gitDirPath>/harness-meta.json` using `HarnessMetaSchema`.
|
|
32
|
+
*
|
|
33
|
+
* Parses the persisted worktree lineage, unresolved conflict digests, and in-flight crash-recovery markers.
|
|
34
|
+
*
|
|
35
|
+
* @param {string} gitDirPath - Path to the worktree's isolated `<gitdir>` metadata directory.
|
|
36
|
+
*
|
|
37
|
+
* @returns {Promise<HarnessMetaRecord>} Validated `HarnessMetaRecord` object.
|
|
38
|
+
*/
|
|
39
|
+
export declare function readHarnessMeta(gitDirPath: string): Promise<HarnessMetaRecord>;
|
|
40
|
+
/**
|
|
41
|
+
* Atomically writes and validates `<gitDirPath>/harness-meta.json` under a cross-process file lock.
|
|
42
|
+
*
|
|
43
|
+
* Acquires `<gitDirPath>/harness-meta.json.lock` via `withFileLock` and persists the validated JSON via `writeFileAtomic`.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} gitDirPath - Path to the worktree's isolated `<gitdir>` metadata directory.
|
|
46
|
+
* @param {HarnessMetaRecord} meta - Metadata record to persist.
|
|
47
|
+
*
|
|
48
|
+
* @returns {Promise<void>} Resolves once `harness-meta.json` is durably updated.
|
|
49
|
+
*/
|
|
50
|
+
export declare function writeHarnessMeta(gitDirPath: string, meta: HarnessMetaRecord): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Updates mutable `GitWorktreeHandle` properties in place when the caller passed a non-frozen handle.
|
|
53
|
+
*
|
|
54
|
+
* Avoids throwing `TypeError` when a caller passes a frozen `GitWorktreeHandle` fixture without
|
|
55
|
+
* using empty `try / catch` blocks.
|
|
56
|
+
*
|
|
57
|
+
* @param {GitWorktreeHandle} handle - Target worktree handle to update.
|
|
58
|
+
* @param {Partial<GitWorktreeHandle>} patch - Partial property updates to assign onto `handle`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function updateWorktreeHandleInPlace(handle: GitWorktreeHandle, patch: Partial<GitWorktreeHandle>): void;
|
|
61
|
+
/**
|
|
62
|
+
* Executes a host-repository worktree administrative operation (`worktree prune`, `worktree add`, `worktree remove`)
|
|
63
|
+
* under `<commonGitDir>/harness-worktree.lock` to prevent concurrent `git worktree` administrative races.
|
|
64
|
+
*
|
|
65
|
+
* @template T Result type returned by `fn`.
|
|
66
|
+
*
|
|
67
|
+
* @param {string} cwd - Working directory inside the host repository or an attached worktree.
|
|
68
|
+
* @param {() => Promise<T>} fn - Async callback performing `git worktree` administrative commands.
|
|
69
|
+
*
|
|
70
|
+
* @returns {Promise<T>} Result produced by `fn`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function withHostWorktreeLock<T>(cwd: string, fn: () => Promise<T>): Promise<T>;
|
|
73
|
+
//# sourceMappingURL=git-cli-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-cli-runner.d.ts","sourceRoot":"","sources":["../../../src/executors/internal/git-cli-runner.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGvE;;;;;;;;;;GAUG;AACH,w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