git-fs-s3 0.8.0 → 0.10.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.
@@ -1,36 +1,35 @@
1
1
  import { type TreeEntry } from "./tree.js";
2
2
  import { type OpsHooks, type Repo } from "./types.js";
3
+ /** How far back history walks look by default (commit count). */
4
+ export declare const HISTORY_WALK_DEPTH = 400;
5
+ export interface GitIdentity {
6
+ name: string;
7
+ email: string;
8
+ timestamp: number;
9
+ timezoneOffset: number;
10
+ }
3
11
  export interface CommitInfo {
4
12
  oid: string;
5
13
  commit: {
6
14
  message: string;
7
15
  tree: string;
8
16
  parent: string[];
9
- author: {
10
- name: string;
11
- email: string;
12
- timestamp: number;
13
- timezoneOffset: number;
14
- };
15
- committer: {
16
- name: string;
17
- email: string;
18
- timestamp: number;
19
- timezoneOffset: number;
20
- };
17
+ author: GitIdentity;
18
+ committer: GitIdentity;
21
19
  };
22
20
  payload: string;
23
21
  }
24
- /**
25
- * Resolve a branch name / full ref / sha to its commit. The ref not
26
- * resolving (unborn branch, genuinely empty repo) and the ref resolving but
27
- * its commit object being unreadable (storage inconsistency — see
28
- * `wrapMissingObject` above) are different failures with different meanings,
29
- * so only the first is left as a raw isomorphic-git NotFoundError for
30
- * callers to treat as "empty"; the second is wrapped into
31
- * GitObjectNotFoundError specifically so it can't be mistaken for the first
32
- * by an `isNotFound`-style check downstream (see getTreeFromRef/getCommitLog).
33
- */
22
+ /** The display summary of a commit (history lists, "last commit" columns). */
23
+ export interface CommitSummary {
24
+ sha: string;
25
+ message: string;
26
+ authorName: string;
27
+ authorEmail: string;
28
+ /** ISO 8601 author date. */
29
+ createdAt: string;
30
+ }
31
+ export declare function summarizeCommit(commit: CommitInfo): CommitSummary;
32
+ /** Resolve a branch name / full ref / sha to its commit. */
34
33
  export declare function resolveCommit(repo: Repo, ref: string): Promise<{
35
34
  oid: string;
36
35
  commit: import("isomorphic-git").CommitObject;
@@ -44,40 +43,28 @@ export declare function getCommit(repo: Repo, sha: string): Promise<CommitInfo>;
44
43
  export interface CommitLogOptions {
45
44
  ref: string;
46
45
  depth?: number;
47
- /**
48
- * Pass the head sha when the caller already resolved `ref` — resolveRef
49
- * tries several candidate paths in sequence and misses the first few every
50
- * time for a normal branch name, which is pure waste when the sha is known.
51
- */
46
+ /** The ref's commit, when the caller already resolved it (saves a lookup). */
52
47
  knownHeadSha?: string;
53
48
  }
54
49
  /**
55
- * The commit chain from a ref, newest first. Walking is inherently sequential
56
- * (each commit's oid is only discoverable by reading its child first) and
57
- * network-round-trip-bound against object storage, so the deepest walk seen
58
- * per head is memoized in `hooks.resultCache` and sliced for shallower or
59
- * repeated requests — don't bypass this by calling `git.log` directly.
50
+ * The commit chain from a ref, newest first; [] when the ref doesn't exist.
51
+ * Walking is sequential and round-trip-bound on object storage, so the
52
+ * deepest walk seen per head is memoized in `hooks.resultCache` and sliced
53
+ * for shallower requests.
60
54
  */
61
55
  export declare function getCommitLog(repo: Repo, options: CommitLogOptions, hooks?: OpsHooks): Promise<CommitInfo[]>;
62
- /** A file at a ref, decoded for display: utf8 text or base64 when binary. */
63
- export declare function getFileFromRef(repo: Repo, filePath: string, ref: string, hooks?: OpsHooks): Promise<{
64
- content: string;
65
- size: number;
66
- isBinary: boolean;
67
- }>;
68
56
  /**
69
57
  * List a directory at the tip of a ref. Throws GitRefNotFoundError when the
70
- * ref doesn't resolve (including an empty repo's unborn branch) and
71
- * GitPathNotFoundError when `treePath` doesn't exist. Results are memoized per
72
- * head sha (auto-invalidates on push).
58
+ * ref doesn't resolve and GitPathNotFoundError when `treePath` doesn't exist.
59
+ * Memoized per head sha.
73
60
  */
74
61
  export declare function getTreeFromRef(repo: Repo, options: {
75
62
  ref: string;
76
63
  treePath?: string;
77
64
  }, hooks?: OpsHooks): Promise<TreeEntry[]>;
78
65
  /**
79
- * A page of commit history from a branch tip. Memoized per head sha; builds
80
- * on {@link getCommitLog}'s walk cache for the underlying chain.
66
+ * A page of commit history from a ref tip; [] when the ref doesn't exist.
67
+ * Pages are slices of {@link getCommitLog}'s memoized walk.
81
68
  */
82
69
  export declare function getCommitHistory(repo: Repo, options: {
83
70
  ref: string;
@@ -1,10 +1,11 @@
1
1
  export { assertBranchExists, assertSafeBranchName, type Branch, createBranchFrom, deleteBranchByName, listBranches, resolveLooseRefFast, } from "./branch.js";
2
2
  export { authorNow, type CommitAuthor, commitFilesToBare, deleteFileFromBare, writeCommitToBare, } from "./commit.js";
3
- export { type DiffFile, type DiffResult, getCommitDiff, getDiffBetweenRefs, MAX_DIFF_TEXT_BYTES, } from "./diff.js";
4
- export { BANNER_WALK_DEPTH, type FileHistoryEntry, type FileHistoryResult, getFileHistory, HISTORY_WALK_DEPTH, } from "./file-history.js";
5
- export { type CommitInfo, type CommitLogOptions, getBlob, getCommit, getCommitHistory, getCommitLog, getFileContent, getFileFromRef, getTreeFromRef, resolveCommit, } from "./history.js";
6
- export { getLastCommitsForTree, type LastCommitInfo, } from "./last-commit.js";
3
+ export { type DiffEntry, type DiffFile, type DiffResult, getCommitDiff, getDiffBetweenRefs, MAX_DIFF_TEXT_BYTES, } from "./diff.js";
4
+ export { BANNER_WALK_DEPTH, type FileHistoryResult, getFileHistory, } from "./file-history.js";
5
+ export { type CommitInfo, type CommitLogOptions, type CommitSummary, type GitIdentity, getBlob, getCommit, getCommitHistory, getCommitLog, getFileContent, getTreeFromRef, HISTORY_WALK_DEPTH, resolveCommit, summarizeCommit, } from "./history.js";
6
+ export { getLastCommitsForTree } from "./last-commit.js";
7
7
  export { analyzeMerge, fastForwardMerge, type MergeAnalysis } from "./merge.js";
8
8
  export { withPackedWrites } from "./packed-writes.js";
9
+ export { getSubmodules, parseGitmodules, type SubmoduleConfig, } from "./submodules.js";
9
10
  export { deleteFromTree, findTreeEntry, listTreeEntries, type TreeEntry, upsertTree, } from "./tree.js";
10
11
  export { type IsoGitFs, type OpsHooks, type Repo, type ResultCache, resultKeyPrefixes, } from "./types.js";
@@ -1,11 +1,5 @@
1
+ import { type CommitSummary } from "./history.js";
1
2
  import type { OpsHooks, Repo } from "./types.js";
2
- export interface LastCommitInfo {
3
- sha: string;
4
- message: string;
5
- authorName: string;
6
- authorEmail: string;
7
- createdAt: string;
8
- }
9
3
  /**
10
4
  * For each direct child of `treePath` (at the tip of `ref`), find the most
11
5
  * recent commit that changed it — the tree view's "last commit" column. Walks
@@ -20,4 +14,4 @@ export declare function getLastCommitsForTree(repo: Repo, options: {
20
14
  ref: string;
21
15
  treePath?: string;
22
16
  depth?: number;
23
- }, hooks?: OpsHooks): Promise<Record<string, LastCommitInfo>>;
17
+ }, hooks?: OpsHooks): Promise<Record<string, CommitSummary>>;
@@ -0,0 +1,13 @@
1
+ import type { OpsHooks, Repo } from "./types.js";
2
+ export interface SubmoduleConfig {
3
+ name: string;
4
+ path: string;
5
+ url: string;
6
+ }
7
+ /**
8
+ * Read only submodule path/url records. Never expands includes, executes Git
9
+ * commands, or fetches URLs. Ambiguous paths and malformed records are ignored.
10
+ */
11
+ export declare function parseGitmodules(content: string): SubmoduleConfig[];
12
+ /** The root .gitmodules at this exact revision; absent/oversized config yields no links. */
13
+ export declare function getSubmodules(repo: Repo, ref: string, hooks?: OpsHooks): Promise<SubmoduleConfig[]>;
@@ -2,7 +2,7 @@ import type { Repo } from "./types.js";
2
2
  export interface TreeEntry {
3
3
  path: string;
4
4
  mode: string;
5
- type: "blob" | "tree";
5
+ type: "blob" | "tree" | "commit";
6
6
  oid: string;
7
7
  size?: number;
8
8
  }
@@ -14,16 +14,16 @@ export interface Repo {
14
14
  }
15
15
  /**
16
16
  * Key/value store for memoizing expensive walk results (commit logs, tree
17
- * listings, per-file history). Keys are namespaced `kind:gitdir:headSha:…`,
18
- * so entries self-invalidate on push (new head, new key) — but evict entries
19
- * under {@link resultKeyPrefixes} after rewriting a repo's storage out of
20
- * band, or stale walks leak until your store's own eviction.
17
+ * listings, per-path history). Keys are namespaced `kind:gitdir:headSha:…`,
18
+ * so entries self-invalidate on push (new head, new key); evict
19
+ * {@link resultKeyPrefixes} to drop a repo's superseded entries early.
20
+ * Values are always objects (arrays or records).
21
21
  */
22
22
  export interface ResultCache {
23
- get<T>(key: string): T | null | undefined;
24
- set(key: string, value: unknown): void;
23
+ get<T extends object>(key: string): T | null | undefined;
24
+ set(key: string, value: object): void;
25
25
  }
26
- /** Optional instrumentation and tuning hooks accepted by every op. */
26
+ /** Optional instrumentation hooks accepted by every op. */
27
27
  export interface OpsHooks {
28
28
  resultCache?: ResultCache;
29
29
  /** Wrap a timed sub-step (network walk, tree listing). Default: run directly. */
@@ -31,21 +31,15 @@ export interface OpsHooks {
31
31
  /** Diagnostic sink for cache hit/miss and walk summaries. */
32
32
  onNote?: (message: string) => void;
33
33
  /**
34
- * Wire pack prefetching (e.g. `GitFs.prefetchPacks`) here so a sequential
35
- * walk doesn't pay one network round trip per commit. Called once before
36
- * history walks of depth >= `prefetchMinDepth` (see below), and
37
- * unconditionally on every cache-miss tree read ({@link getTreeFromRef}) —
38
- * a tree read has no shallow case, it always needs at least the head
39
- * commit's tree object.
34
+ * Warm every pack (e.g. `GitFs.prefetchPacks`) before a cache-miss read,
35
+ * so a sequential walk doesn't discover packs one round trip at a time.
40
36
  */
41
37
  prefetch?: () => Promise<void>;
42
- /** Minimum walk depth before `prefetch` fires for history walks. Default 5. */
43
- prefetchMinDepth?: number;
44
38
  }
45
39
  export declare const runStep: <T>(hooks: OpsHooks | undefined, label: string, fn: () => Promise<T>) => Promise<T>;
46
40
  /**
47
41
  * The result-cache key prefixes holding entries for `gitdir` — evict these
48
42
  * from your {@link ResultCache} when the repo's storage was rewritten outside
49
- * a normal push (bulk sync, rename, repack cleanup).
43
+ * a normal push (rename, repack).
50
44
  */
51
45
  export declare function resultKeyPrefixes(gitdir: string): string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "git-fs-s3",
3
- "version": "0.8.0",
4
- "description": "isomorphic-git filesystem backend for S3-compatible object storage (AWS S3, Cloudflare R2, MinIO) \u2014 run git servers without a disk",
3
+ "version": "0.10.0",
4
+ "description": "isomorphic-git filesystem backend for S3-compatible object storage (AWS S3, Cloudflare R2, MinIO) — run git servers without a disk",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {