just-git 1.5.6 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +342 -338
- package/dist/repo/index.d.ts +137 -2
- package/dist/repo/index.js +19 -18
- package/dist/server/index.d.ts +1 -1
- package/dist/{writing-IwfRRrts.d.ts → writing-CF-eYohc.d.ts} +1 -1
- package/package.json +1 -1
package/dist/repo/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { g as GitRepo, Z as RefEntry, e as Commit, a3 as TreeEntry, i as ObjectId, h as Identity, a4 as TreeDiffEntry, d as GitContext, F as FileSystem } from '../hooks-CimfP56a.js';
|
|
2
|
-
export { B as BuildCommitOptions,
|
|
2
|
+
export { B as BuildCommitOptions, b as CommitAuthor, c as CommitIdentity, C as CommitOptions, a as CommitResult, d as CreateAnnotatedTagOptions, e as CreateCommitOptions, T as TreeEntryInput, f as TreeUpdate, g as buildCommit, h as commit, i as createAnnotatedTag, j as createCommit, u as updateTree, w as writeBlob, k as writeTree } from '../writing-CF-eYohc.js';
|
|
3
3
|
|
|
4
4
|
/** Extract the short branch name from a full ref path like "refs/heads/main" → "main". */
|
|
5
5
|
declare function branchNameFromRef(ref: string): string;
|
|
@@ -405,6 +405,141 @@ declare function createSandboxWorktree(repo: GitRepo, options?: {
|
|
|
405
405
|
gitDir?: string;
|
|
406
406
|
}): Promise<WorktreeResult>;
|
|
407
407
|
|
|
408
|
+
/** Minimal filesystem surface needed to write a materialized tree. */
|
|
409
|
+
interface MaterializeTarget {
|
|
410
|
+
writeFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
411
|
+
mkdir(path: string, options?: {
|
|
412
|
+
recursive?: boolean;
|
|
413
|
+
}): Promise<void>;
|
|
414
|
+
symlink?(target: string, path: string): Promise<void>;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Lazy accessor for the worktree contents at a specific tree.
|
|
419
|
+
*
|
|
420
|
+
* Provides progressively richer access to files without requiring
|
|
421
|
+
* upfront materialization:
|
|
422
|
+
*
|
|
423
|
+
* - {@link readFile} / {@link readFileBytes} — read a single file (O(tree depth), no flatten)
|
|
424
|
+
* - {@link files} — list all tracked file paths (walks tree objects, no blob reads)
|
|
425
|
+
* - {@link fs} — get a full {@link FileSystem} view (lazy reads, in-memory writes)
|
|
426
|
+
* - {@link materialize} — write all tracked files onto a target filesystem
|
|
427
|
+
*/
|
|
428
|
+
interface TreeAccessor {
|
|
429
|
+
/** The underlying git tree object hash. */
|
|
430
|
+
readonly treeHash: string;
|
|
431
|
+
/** Read a file's text content. Returns `null` if the file doesn't exist. */
|
|
432
|
+
readFile(path: string): Promise<string | null>;
|
|
433
|
+
/** Read a file's raw bytes. Returns `null` if the file doesn't exist. */
|
|
434
|
+
readFileBytes(path: string): Promise<Uint8Array | null>;
|
|
435
|
+
/** List all tracked file paths (no blob content is read). */
|
|
436
|
+
files(): Promise<string[]>;
|
|
437
|
+
/**
|
|
438
|
+
* Get a full `FileSystem` backed by this tree.
|
|
439
|
+
*
|
|
440
|
+
* Files are read lazily from the object store on demand.
|
|
441
|
+
* Writes go to an in-memory overlay and never touch the repo.
|
|
442
|
+
* Created once on first call, then cached for the lifetime of this accessor.
|
|
443
|
+
*/
|
|
444
|
+
fs(root?: string): FileSystem;
|
|
445
|
+
/**
|
|
446
|
+
* Write all tracked files onto a filesystem.
|
|
447
|
+
*
|
|
448
|
+
* @param target — target filesystem (only needs `mkdir`, `writeFile`,
|
|
449
|
+
* and optionally `symlink`)
|
|
450
|
+
* @param targetDir — root directory on the target fs (default `"/"`)
|
|
451
|
+
* @returns the number of files written
|
|
452
|
+
*/
|
|
453
|
+
materialize(target: MaterializeTarget, targetDir?: string): Promise<number>;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Create a lazy {@link TreeAccessor} for a git tree hash.
|
|
457
|
+
*
|
|
458
|
+
* Single-file reads use O(tree depth) traversal via {@link TreeBackedFs}.
|
|
459
|
+
* Full-tree operations (`files`, `materialize`) flatten on demand.
|
|
460
|
+
*/
|
|
461
|
+
declare function createTreeAccessor(repo: GitRepo, treeHash: string): TreeAccessor;
|
|
462
|
+
|
|
463
|
+
/** Options for {@link bisect}. */
|
|
464
|
+
interface BisectOptions {
|
|
465
|
+
/** Known bad commit (hash, branch, tag, or any rev-parse expression). */
|
|
466
|
+
bad: string;
|
|
467
|
+
/** One or more known good commits. */
|
|
468
|
+
good: string | string[];
|
|
469
|
+
/**
|
|
470
|
+
* Test a candidate commit. Return:
|
|
471
|
+
* - `true` — commit is good (bug not present)
|
|
472
|
+
* - `false` — commit is bad (bug present)
|
|
473
|
+
* - `"skip"` — commit is untestable
|
|
474
|
+
*
|
|
475
|
+
* The `tree` parameter provides lazy access to the worktree contents
|
|
476
|
+
* at the candidate commit — read individual files, list paths, or
|
|
477
|
+
* get a full `FileSystem` for build/test scenarios.
|
|
478
|
+
*/
|
|
479
|
+
test: (hash: string, tree: TreeAccessor) => boolean | "skip" | Promise<boolean | "skip">;
|
|
480
|
+
/** Follow only first parent at merge commits (default false). */
|
|
481
|
+
firstParent?: boolean;
|
|
482
|
+
/** Called after each step with progress info. */
|
|
483
|
+
onStep?: (info: BisectStepInfo) => void;
|
|
484
|
+
}
|
|
485
|
+
/** Progress info passed to {@link BisectOptions.onStep}. */
|
|
486
|
+
interface BisectStepInfo {
|
|
487
|
+
hash: string;
|
|
488
|
+
subject: string;
|
|
489
|
+
verdict: "good" | "bad" | "skip";
|
|
490
|
+
remaining: number;
|
|
491
|
+
estimatedSteps: number;
|
|
492
|
+
stepNumber: number;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Result of {@link bisect}.
|
|
496
|
+
*
|
|
497
|
+
* - `found: true` — the first bad commit was identified.
|
|
498
|
+
* - `found: false, reason: "all-skipped"` — only skipped commits remain;
|
|
499
|
+
* `candidates` lists them (plus the current bad).
|
|
500
|
+
* - `found: false, reason: "no-testable-commits"` — no commits exist
|
|
501
|
+
* between the good and bad boundaries.
|
|
502
|
+
*/
|
|
503
|
+
type BisectSearchResult = {
|
|
504
|
+
found: true;
|
|
505
|
+
hash: string;
|
|
506
|
+
stepsTaken: number;
|
|
507
|
+
} | {
|
|
508
|
+
found: false;
|
|
509
|
+
reason: "all-skipped";
|
|
510
|
+
candidates: string[];
|
|
511
|
+
} | {
|
|
512
|
+
found: false;
|
|
513
|
+
reason: "no-testable-commits";
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* Binary-search the commit graph to find the first bad commit.
|
|
517
|
+
*
|
|
518
|
+
* Operates purely on the object store — no filesystem, index, working
|
|
519
|
+
* tree, or state files. The caller provides a `test` callback that
|
|
520
|
+
* inspects each candidate commit and returns whether it is good, bad,
|
|
521
|
+
* or should be skipped.
|
|
522
|
+
*
|
|
523
|
+
* Uses the same weighted-midpoint algorithm as `git bisect`: each step
|
|
524
|
+
* picks the commit that maximizes information gain (closest to
|
|
525
|
+
* eliminating half the remaining candidates).
|
|
526
|
+
*
|
|
527
|
+
* ```ts
|
|
528
|
+
* const result = await bisect(repo, {
|
|
529
|
+
* bad: "main",
|
|
530
|
+
* good: "v1.0.0",
|
|
531
|
+
* test: async (hash, tree) => {
|
|
532
|
+
* const content = await tree.readFile("src/config.ts");
|
|
533
|
+
* return content !== null && !content.includes("broken_call");
|
|
534
|
+
* },
|
|
535
|
+
* });
|
|
536
|
+
* if (result.found) {
|
|
537
|
+
* console.log(`First bad commit: ${result.hash}`);
|
|
538
|
+
* }
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
declare function bisect(repo: GitRepo, options: BisectOptions): Promise<BisectSearchResult>;
|
|
542
|
+
|
|
408
543
|
/**
|
|
409
544
|
* Wrap a `GitRepo` so all write operations throw.
|
|
410
545
|
*
|
|
@@ -439,4 +574,4 @@ declare function readonlyRepo(repo: GitRepo): GitRepo;
|
|
|
439
574
|
*/
|
|
440
575
|
declare function overlayRepo(repo: GitRepo): GitRepo;
|
|
441
576
|
|
|
442
|
-
export { type BlameEntry, Commit, type CommitInfo, type CreateWorktreeOptions, type DiffHunk, type DiffOptions, type ExtractTreeResult, type FileDiff, type FlatTreeEntry, GitRepo, type GrepFileMatch, type GrepMatch, type GrepOptions, type HeadInfo, Identity, type MergeConflict, type MergeTreesResult, RefEntry, TreeDiffEntry, TreeEntry, type WorktreeResult, blame, branchNameFromRef, countAheadBehind, createSandboxWorktree, createWorktree, diffCommits, diffTrees, extractTree, findMergeBases, flattenTree, formatDiff, getChangedFiles, getNewCommits, grep, isAncestor, listBranches, listTags, mergeTrees, mergeTreesFromTreeHashes, overlayRepo, readBlob, readBlobText, readCommit, readFileAtCommit, readHead, readTree, readonlyRepo, resolveRef, tagNameFromRef, walkCommitHistory };
|
|
577
|
+
export { type BisectOptions, type BisectSearchResult, type BisectStepInfo, type BlameEntry, Commit, type CommitInfo, type CreateWorktreeOptions, type DiffHunk, type DiffOptions, type ExtractTreeResult, type FileDiff, type FlatTreeEntry, GitRepo, type GrepFileMatch, type GrepMatch, type GrepOptions, type HeadInfo, Identity, type MaterializeTarget, type MergeConflict, type MergeTreesResult, RefEntry, type TreeAccessor, TreeDiffEntry, TreeEntry, type WorktreeResult, bisect, blame, branchNameFromRef, countAheadBehind, createSandboxWorktree, createTreeAccessor, createWorktree, diffCommits, diffTrees, extractTree, findMergeBases, flattenTree, formatDiff, getChangedFiles, getNewCommits, grep, isAncestor, listBranches, listTags, mergeTrees, mergeTreesFromTreeHashes, overlayRepo, readBlob, readBlobText, readCommit, readFileAtCommit, readHead, readTree, readonlyRepo, resolveRef, tagNameFromRef, walkCommitHistory };
|