just-git 1.5.9 → 1.5.11

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.
@@ -1,5 +1,6 @@
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, C as CommitAuthor, a as CommitIdentity, b as CommitOptions, c 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-IwfRRrts.js';
2
+ import { C as CommitIdentity } from '../writing-CEP3N60d.js';
3
+ export { B as BuildCommitOptions, a as CommitAuthor, b as CommitOptions, c 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-CEP3N60d.js';
3
4
 
4
5
  /** Extract the short branch name from a full ref path like "refs/heads/main" → "main". */
5
6
  declare function branchNameFromRef(ref: string): string;
@@ -17,6 +18,19 @@ interface GrepMatch {
17
18
 
18
19
  /** Resolve a ref name (e.g. "HEAD", "refs/heads/main") to a commit hash. Returns null if not found. */
19
20
  declare function resolveRef(repo: GitRepo, name: string): Promise<string | null>;
21
+ /**
22
+ * Resolve a revision expression to an object hash.
23
+ *
24
+ * Supports branch names, tag names, `HEAD`, short hashes, special refs
25
+ * (`ORIG_HEAD`, `MERGE_HEAD`, etc.), remote tracking refs (`origin/main`),
26
+ * `~N`/`^N` suffixes, `^{commit}`/`^{tree}` peel syntax, and arbitrary
27
+ * chaining (`main~2^2`, `v1.0^{commit}~3`).
28
+ *
29
+ * Returns null if the revision cannot be resolved. Reflog syntax
30
+ * (`@{N}`) is not supported — reflog entries require filesystem access
31
+ * and are not available through `GitRepo`.
32
+ */
33
+ declare function revParse(repo: GitRepo, rev: string): Promise<string | null>;
20
34
  /** List all local branches (`refs/heads/*`). */
21
35
  declare function listBranches(repo: GitRepo): Promise<RefEntry[]>;
22
36
  /** List all tags (`refs/tags/*`). */
@@ -580,6 +594,135 @@ type BisectSearchResult = {
580
594
  * ```
581
595
  */
582
596
  declare function bisect(repo: GitRepo, options: BisectOptions): Promise<BisectSearchResult>;
597
+ /** Options for {@link cherryPick}. */
598
+ interface CherryPickOptions {
599
+ /** The commit to cherry-pick (hash, branch, tag, or any rev-parse expression). */
600
+ commit: string;
601
+ /** The commit to apply on top of (hash, branch, tag, or any rev-parse expression). */
602
+ onto: string;
603
+ /** Branch to advance on clean result. No ref update when omitted. Ignored when `noCommit` is true. */
604
+ branch?: string;
605
+ /** Committer identity. Defaults to the original commit's author when omitted, so both author and committer will reflect the original — pass explicitly to record who performed the cherry-pick. */
606
+ committer?: CommitIdentity;
607
+ /** Parent number for merge commits (1-based). Required when cherry-picking a merge. */
608
+ mainline?: number;
609
+ /** Append "(cherry picked from commit ...)" trailer to the message. */
610
+ recordOrigin?: boolean;
611
+ /** Override the commit message. Defaults to the original commit's message. */
612
+ message?: string;
613
+ /** When true, perform the merge but don't create a commit. `hash` will be `null` in the result. */
614
+ noCommit?: boolean;
615
+ /** Custom merge driver for content conflicts. */
616
+ mergeDriver?: MergeDriver;
617
+ }
618
+ /** Clean result when a commit was created. */
619
+ interface CleanPickCommitted {
620
+ clean: true;
621
+ hash: string;
622
+ treeHash: string;
623
+ }
624
+ /** Clean result when `noCommit` was set — no commit created. */
625
+ interface CleanPickNoCommit {
626
+ clean: true;
627
+ treeHash: string;
628
+ }
629
+ /** Conflict result — no commit was created. */
630
+ interface PickConflict {
631
+ clean: false;
632
+ treeHash: string;
633
+ conflicts: MergeConflict[];
634
+ messages: string[];
635
+ }
636
+ /**
637
+ * Result of {@link cherryPick} or {@link revert}.
638
+ *
639
+ * - `clean: true` with `hash` — commit was created.
640
+ * - `clean: true` without `hash` — `noCommit` was set, merge succeeded
641
+ * but no commit was created.
642
+ * - `clean: false` — conflicts were found, no commit was created.
643
+ */
644
+ type CherryPickResult = CleanPickCommitted | PickConflict;
645
+ /** Result of {@link cherryPick} or {@link revert} when `noCommit` is true. */
646
+ type NoCommitPickResult = CleanPickNoCommit | PickConflict;
647
+ /**
648
+ * Cherry-pick a commit onto another commit.
649
+ *
650
+ * Applies the changes introduced by `commit` on top of `onto` using a
651
+ * three-way merge (base = parent of `commit`, ours = `onto`, theirs = `commit`).
652
+ * Operates purely on the object store — no filesystem, index, or working tree.
653
+ *
654
+ * On a clean result, creates a new commit preserving the original author.
655
+ * When `branch` is provided, the branch ref is advanced to the new commit.
656
+ *
657
+ * ```ts
658
+ * const result = await cherryPick(repo, {
659
+ * commit: "feature~2",
660
+ * onto: "main",
661
+ * branch: "main",
662
+ * committer: { name: "Bot", email: "bot@example.com" },
663
+ * });
664
+ * if (result.clean) {
665
+ * console.log(`Cherry-picked as ${result.hash}`);
666
+ * } else {
667
+ * console.log(`Conflicts: ${result.conflicts.length}`);
668
+ * }
669
+ * ```
670
+ */
671
+ declare function cherryPick(repo: GitRepo, options: CherryPickOptions & {
672
+ noCommit: true;
673
+ }): Promise<NoCommitPickResult>;
674
+ declare function cherryPick(repo: GitRepo, options: CherryPickOptions): Promise<CherryPickResult>;
675
+ /** Options for {@link revert}. */
676
+ interface RevertOptions {
677
+ /** The commit to revert (hash, branch, tag, or any rev-parse expression). */
678
+ commit: string;
679
+ /** The commit to apply the revert on top of (hash, branch, tag, or any rev-parse expression). */
680
+ onto: string;
681
+ /** Branch to advance on clean result. No ref update when omitted. Ignored when `noCommit` is true. */
682
+ branch?: string;
683
+ /** Committer identity. Defaults to the caller's identity. When omitted, uses `author` as both author and committer. */
684
+ committer?: CommitIdentity;
685
+ /** Author identity for the revert commit. When omitted, uses `committer`. At least one of `author` or `committer` must be provided (unless `noCommit` is true). */
686
+ author?: CommitIdentity;
687
+ /** Parent number for merge commits (1-based). Required when reverting a merge. */
688
+ mainline?: number;
689
+ /** Override the commit message. Defaults to the auto-generated "Revert ..." message. */
690
+ message?: string;
691
+ /** When true, perform the merge but don't create a commit. `hash` will be `null` in the result. */
692
+ noCommit?: boolean;
693
+ /** Custom merge driver for content conflicts. */
694
+ mergeDriver?: MergeDriver;
695
+ }
696
+ /** Result of {@link revert}. Same shape as {@link CherryPickResult}. */
697
+ type RevertResult = CherryPickResult;
698
+ /** Result of {@link revert} when `noCommit` is true. */
699
+ type NoCommitRevertResult = NoCommitPickResult;
700
+ /**
701
+ * Revert a commit on top of another commit.
702
+ *
703
+ * Applies the inverse of the changes introduced by `commit` on top of
704
+ * `onto` using a three-way merge (base = `commit`, ours = `onto`,
705
+ * theirs = parent of `commit`). Operates purely on the object store.
706
+ *
707
+ * On a clean result, creates a new commit with a "Revert ..." message.
708
+ * When `branch` is provided, the branch ref is advanced.
709
+ *
710
+ * ```ts
711
+ * const result = await revert(repo, {
712
+ * commit: "abc1234",
713
+ * onto: "main",
714
+ * branch: "main",
715
+ * committer: { name: "Bot", email: "bot@example.com" },
716
+ * });
717
+ * if (result.clean) {
718
+ * console.log(`Reverted as ${result.hash}`);
719
+ * }
720
+ * ```
721
+ */
722
+ declare function revert(repo: GitRepo, options: RevertOptions & {
723
+ noCommit: true;
724
+ }): Promise<NoCommitRevertResult>;
725
+ declare function revert(repo: GitRepo, options: RevertOptions): Promise<RevertResult>;
583
726
 
584
727
  /**
585
728
  * Wrap a `GitRepo` so all write operations throw.
@@ -615,4 +758,4 @@ declare function readonlyRepo(repo: GitRepo): GitRepo;
615
758
  */
616
759
  declare function overlayRepo(repo: GitRepo): GitRepo;
617
760
 
618
- 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 MergeDriver, type MergeDriverResult, 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 };
761
+ export { type BisectOptions, type BisectSearchResult, type BisectStepInfo, type BlameEntry, type CherryPickOptions, type CherryPickResult, type CleanPickCommitted, type CleanPickNoCommit, Commit, CommitIdentity, 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 MergeDriver, type MergeDriverResult, type MergeTreesResult, type NoCommitPickResult, type NoCommitRevertResult, type PickConflict, RefEntry, type RevertOptions, type RevertResult, type TreeAccessor, TreeDiffEntry, TreeEntry, type WorktreeResult, bisect, blame, branchNameFromRef, cherryPick, 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, revParse, revert, tagNameFromRef, walkCommitHistory };