git-edge 0.2.1 → 0.2.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 +11 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://github.com/nandan-varma/git-edge/actions/workflows/ci.yml)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
High-level edge-compatible git operations on top of [isomorphic-git](https://isomorphic-git.org): a parsed-object LRU cache, an object-level three-way merge that never needs a worktree, and repo-cache
|
|
7
|
+
High-level edge-compatible git operations on top of [isomorphic-git](https://isomorphic-git.org): a parsed-object LRU cache, an object-level three-way merge that never needs a worktree, and per-repo packfile-cache management. No `node:*` imports anywhere in `src/` — runs on Cloudflare Workers, Vercel Edge, Deno Deploy, and Node.
|
|
8
8
|
|
|
9
9
|
Extracted from the same production git-hosting service as [`git-fs-s3`](https://www.npmjs.com/package/git-fs-s3) — the two compose (see below) but neither imports the other; both just agree on isomorphic-git's `{ fs, gitdir, cache? }` shape.
|
|
10
10
|
|
|
@@ -49,13 +49,14 @@ try {
|
|
|
49
49
|
### With git-fs-s3
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
+
import git from "isomorphic-git";
|
|
52
53
|
import { createGitFs, MemoryObjectStore } from "git-fs-s3";
|
|
53
|
-
import { threeWayMerge
|
|
54
|
+
import { threeWayMerge } from "git-edge";
|
|
54
55
|
|
|
55
56
|
const fs = createGitFs(new MemoryObjectStore());
|
|
56
57
|
const repo = { fs, gitdir: "/repo.git", cache: {} };
|
|
57
58
|
|
|
58
|
-
await
|
|
59
|
+
await git.init({ ...repo, dir: repo.gitdir, bare: true });
|
|
59
60
|
// ... commits land on "feature" and "main" via git-fs-s3's fs ...
|
|
60
61
|
await threeWayMerge(repo, "feature", "main");
|
|
61
62
|
```
|
|
@@ -73,9 +74,11 @@ Merges `sourceRef` into `targetRef` at the object level — no worktree.
|
|
|
73
74
|
|
|
74
75
|
Returns `{ commitOid }` — the new merge commit, or the fast-forwarded `targetRef`'s new oid.
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
Want a cheap pre-merge check (resolve both refs, check ancestry, no tree walk
|
|
78
|
+
— "would this be a fast-forward, or has it diverged") before deciding whether
|
|
79
|
+
to show a "conflicts likely" hint in a UI? That's `git-fs-s3/ops`'s
|
|
80
|
+
`analyzeMerge`, not this package's — it composes with `threeWayMerge` (same
|
|
81
|
+
`{ fs, gitdir, cache? }` shape) without either package importing the other.
|
|
79
82
|
|
|
80
83
|
### `createParsedObjectCache(options?)`
|
|
81
84
|
|
|
@@ -96,23 +99,15 @@ cache.invalidatePrefix(gitdir); // drop everything under a repo after a rewrite
|
|
|
96
99
|
|
|
97
100
|
Per-repo isomorphic-git packfile `cache` object management, keyed `` `${ownerKey}/${repoName}` ``. isomorphic-git treats this `cache` as opaque and safe to share indefinitely (git objects are content-addressed/immutable), so a long-lived per-repo instance turns "reparse this pack's index" from once-per-call into once-per-process. Call `invalidateRepoCache` after anything rewrites a repo's storage out from under a live process (a rename, a bulk resync) so stale parsed state can't leak into the next read.
|
|
98
101
|
|
|
99
|
-
### `initBareRepo(repo, defaultBranch?)`
|
|
100
|
-
|
|
101
|
-
Thin wrapper over `git.init({ ...repo, bare: true })` — accepts any fs (git-fs-s3-backed, `node:fs`, in-memory), defaults `defaultBranch` to `"main"`.
|
|
102
|
-
|
|
103
|
-
### `estimateRepoSize(repo, stat, list)`
|
|
104
|
-
|
|
105
|
-
Sums `.pack`/loose-object file sizes under `objects/`. Caller supplies `stat`/`list` since "size of a file" isn't part of isomorphic-git's own `fs` contract — for `node:fs` that's `fs.stat`/`fs.readdir`; for an object-storage-backed fs it's typically a HEAD request per key. Can be expensive against remote storage — prefer tracking size incrementally at write time where possible.
|
|
106
|
-
|
|
107
102
|
### Errors
|
|
108
103
|
|
|
109
104
|
`GitEdgeError` — base class. `GitMergeConflictError extends GitEdgeError` — `conflictingPaths: string[]`, thrown only by `threeWayMerge`.
|
|
110
105
|
|
|
111
106
|
## Semantics & limitations
|
|
112
107
|
|
|
113
|
-
- `threeWayMerge`'s content merge
|
|
108
|
+
- `threeWayMerge`'s content merge (for paths both sides changed from the merge base — most changes are added/deleted/single-side-modified and resolve without touching it at all) uses [`node-diff3`](https://www.npmjs.com/package/node-diff3)'s LCS-based diff3 algorithm, the same approach GNU diffutils' `diff3` and git's own default merge driver use.
|
|
114
109
|
- No binary-file merge support — conflict markers are written as text into whatever bytes the paths held; binary content will produce a nonsensical merged blob, not a clean conflict signal. Detect binary paths upstream if that matters for your use case.
|
|
115
|
-
-
|
|
110
|
+
- The parsed-object cache and `getRepoCache`/`invalidateRepoCache` are general-purpose helpers, not required by `threeWayMerge` — use whichever pieces you need independently.
|
|
116
111
|
|
|
117
112
|
## License
|
|
118
113
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-edge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "High-level edge-compatible git operations — parsed-object cache, object-level three-way merge, and repo management utilities. Composes with git-fs-s3.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|