just-git 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![client size](https://img.shields.io/bundlejs/size/just-git?label=client)](https://bundlejs.com/?q=just-git)
6
6
  [![server size](https://img.shields.io/bundlejs/size/just-git/server?label=server)](https://bundlejs.com/?q=just-git/server)
7
7
 
8
- Pure TypeScript git implementation. Zero dependencies. 36 commands. Works in Node, Bun, Deno, Cloudflare Workers, and the browser. [Tested against real git](docs/TESTING.md) across more than a million randomized operations.
8
+ Pure TypeScript git implementation. Zero dependencies. 36 commands. Works in Node, Bun, Deno, Cloudflare Workers, and the browser. [Tested against real git](docs/TESTING.md) across millions of randomized operations.
9
9
 
10
10
  The Git CLI, Git servers, and CI workflows are no longer just things you use to develop apps: they can be part of the apps themselves. The goal of this project is to make that practical.
11
11
 
@@ -62,6 +62,15 @@ await git.exec('git commit -m "initial commit"');
62
62
 
63
63
  Both `fs` and `cwd` can be set once in `createGit` and overridden per-call. `cwd` defaults to `"/"`. Set it to the repo root so every `exec` call finds `.git` automatically.
64
64
 
65
+ Use `git.findRepo()` to get a `GitContext` for programmatic access via the [repo module](docs/REPO.md). It threads through all operator extensions (hooks, identity, credentials, config overrides) automatically:
66
+
67
+ ```ts
68
+ const repo = await git.findRepo();
69
+ if (repo) {
70
+ const diff = await diffCommits(repo, parentHash, headHash);
71
+ }
72
+ ```
73
+
65
74
  `createGit` also supports:
66
75
 
67
76
  - [Command restrictions, network policies, and config overrides](docs/CLIENT.md#options) for sandboxing
@@ -623,4 +623,4 @@ interface GitHooks {
623
623
  */
624
624
  declare function composeGitHooks(...hookSets: (GitHooks | undefined)[]): GitHooks;
625
625
 
626
- export { type RefUpdateEvent as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type DirectRef as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PreCloneEvent as J, type PreCommitEvent as K, type PreFetchEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type ProgressCallback as P, type PreMergeCommitEvent as Q, type RemoteResolver as R, type PrePullEvent as S, type PrePushEvent as T, type PreRebaseEvent as U, type PreResetEvent as V, type PreRevertEvent as W, type RawObject as X, type Ref as Y, type RefDeleteEvent as Z, type RefEntry as _, type RefStore as a, type Rejection as a0, type SymbolicRef as a1, composeGitHooks as a2, isRejection as a3, type TreeEntry as a4, type TreeDiffEntry as a5, type ConfigOverrides as b, type FileStat as c, type GitContext as d, type Commit as e, type CommitMsgEvent as f, type GitRepo as g, type Identity as h, type ObjectId as i, type ObjectType as j, type ObjectWriteEvent as k, type PackObject as l, type PostApplyEvent as m, type PostCheckoutEvent as n, type PostCherryPickEvent as o, type PostCloneEvent as p, type PostCommitEvent as q, type PostFetchEvent as r, type PostMergeEvent as s, type PostPullEvent as t, type PostPushEvent as u, type PostResetEvent as v, type PostRevertEvent as w, type PreApplyEvent as x, type PreCheckoutEvent as y, type PreCherryPickEvent as z };
626
+ export { type RefUpdateEvent as $, type AfterCommandEvent as A, type BeforeCommandEvent as B, type CredentialProvider as C, type DirectRef as D, type ExecResult as E, type FileSystem as F, type GitHooks as G, type HttpAuth as H, type IdentityOverride as I, type PreCloneEvent as J, type PreCommitEvent as K, type PreFetchEvent as L, type MergeMsgEvent as M, type NetworkPolicy as N, type ObjectStore as O, type ProgressCallback as P, type PreMergeCommitEvent as Q, type RemoteResolver as R, type PrePullEvent as S, type PrePushEvent as T, type PreRebaseEvent as U, type PreResetEvent as V, type PreRevertEvent as W, type RawObject as X, type Ref as Y, type RefDeleteEvent as Z, type RefEntry as _, type RefStore as a, type Rejection as a0, type SymbolicRef as a1, composeGitHooks as a2, isRejection as a3, type TreeEntry as a4, type TreeDiffEntry as a5, type ConfigOverrides as b, type GitContext as c, type FileStat as d, type Commit as e, type CommitMsgEvent as f, type GitRepo as g, type Identity as h, type ObjectId as i, type ObjectType as j, type ObjectWriteEvent as k, type PackObject as l, type PostApplyEvent as m, type PostCheckoutEvent as n, type PostCherryPickEvent as o, type PostCloneEvent as p, type PostCommitEvent as q, type PostFetchEvent as r, type PostMergeEvent as s, type PostPullEvent as t, type PostPushEvent as u, type PostResetEvent as v, type PostRevertEvent as w, type PreApplyEvent as x, type PreCheckoutEvent as y, type PreCherryPickEvent as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, P as ProgressCallback, E as ExecResult, c as FileStat, d as GitContext } from './hooks-pZgz2y6k.js';
2
- export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, l as PackObject, m as PostApplyEvent, n as PostCheckoutEvent, o as PostCherryPickEvent, p as PostCloneEvent, q as PostCommitEvent, r as PostFetchEvent, s as PostMergeEvent, t as PostPullEvent, u as PostPushEvent, v as PostResetEvent, w as PostRevertEvent, x as PreApplyEvent, y as PreCheckoutEvent, z as PreCherryPickEvent, J as PreCloneEvent, K as PreCommitEvent, L as PreFetchEvent, Q as PreMergeCommitEvent, S as PrePullEvent, T as PrePushEvent, U as PreRebaseEvent, V as PreResetEvent, W as PreRevertEvent, X as RawObject, Y as Ref, Z as RefDeleteEvent, _ as RefEntry, $ as RefUpdateEvent, a0 as Rejection, a1 as SymbolicRef, a2 as composeGitHooks, a3 as isRejection } from './hooks-pZgz2y6k.js';
1
+ import { F as FileSystem, G as GitHooks, C as CredentialProvider, I as IdentityOverride, N as NetworkPolicy, R as RemoteResolver, O as ObjectStore, a as RefStore, b as ConfigOverrides, P as ProgressCallback, c as GitContext, E as ExecResult, d as FileStat } from './hooks-BcVLl-zm.js';
2
+ export { A as AfterCommandEvent, B as BeforeCommandEvent, e as Commit, f as CommitMsgEvent, D as DirectRef, g as GitRepo, H as HttpAuth, h as Identity, M as MergeMsgEvent, i as ObjectId, j as ObjectType, k as ObjectWriteEvent, l as PackObject, m as PostApplyEvent, n as PostCheckoutEvent, o as PostCherryPickEvent, p as PostCloneEvent, q as PostCommitEvent, r as PostFetchEvent, s as PostMergeEvent, t as PostPullEvent, u as PostPushEvent, v as PostResetEvent, w as PostRevertEvent, x as PreApplyEvent, y as PreCheckoutEvent, z as PreCherryPickEvent, J as PreCloneEvent, K as PreCommitEvent, L as PreFetchEvent, Q as PreMergeCommitEvent, S as PrePullEvent, T as PrePushEvent, U as PreRebaseEvent, V as PreResetEvent, W as PreRevertEvent, X as RawObject, Y as Ref, Z as RefDeleteEvent, _ as RefEntry, $ as RefUpdateEvent, a0 as Rejection, a1 as SymbolicRef, a2 as composeGitHooks, a3 as isRejection } from './hooks-BcVLl-zm.js';
3
3
  import { M as MergeDriver } from './merge-ort-BYMritNd.js';
4
4
  export { a as MergeDriverResult } from './merge-ort-BYMritNd.js';
5
5
 
@@ -125,10 +125,33 @@ declare class Git {
125
125
  private defaultCwd;
126
126
  private blocked;
127
127
  private hooks;
128
+ private ext;
128
129
  private inner;
129
130
  private locks;
130
131
  private withLock;
131
132
  constructor(options?: GitOptions);
133
+ /**
134
+ * Discover the git repository for the current working directory.
135
+ *
136
+ * Uses the instance's default `fs` and `cwd`, with optional per-call
137
+ * overrides. The returned {@link GitContext} carries all operator-level
138
+ * extensions (hooks, identity, credentials, config overrides) configured
139
+ * on this instance, so repo SDK functions receive the full context.
140
+ *
141
+ * When the instance was created with explicit `objectStore`, `refStore`,
142
+ * and `gitDir`, filesystem discovery is skipped entirely.
143
+ *
144
+ * ```ts
145
+ * const repo = await git.findRepo();
146
+ * if (repo) {
147
+ * const history = await walkCommitHistory(repo, headHash);
148
+ * }
149
+ * ```
150
+ */
151
+ findRepo(ctx?: {
152
+ fs?: FileSystem;
153
+ cwd?: string;
154
+ }): Promise<GitContext | null>;
132
155
  /**
133
156
  * Run a git command from a string.
134
157
  *