Expand description
Git history walk + blob content (git2 layer).
Given a repo and a doc path (relative to repo root), list every commit that
touched it — newest-first — paired with the file content at that revision and
at its first parent. Rename-aware via diff find_similar, first-commit-safe,
no-history-safe.
History selection mirrors git log -- <path>: the walk is over all
reachable commits but a merge commit that is TREESAME (same blob at the
tracked path) to one of its parents is simplified out, so a side-branch
change is not duplicated under the merge subject. Rename following uses
git2’s find_similar with an explicit 50% similarity threshold (git’s
default); a rename that also rewrites the body below that threshold is seen
as add+delete rather than a rename, so — like git without --follow — the
pre-rename history is not stitched across in that case. Copy detection is
off (parity with the original, which relied on git log’s default rename
following).
Structs§
- Commit
Meta - Commit metadata captured for a revision.
- Global
File Change - One changed doc file within a single commit (the
newside, plus itsoldcontent from the first parent). The global analogue of the per-fileRevisionContent. - Global
Revision - One commit in the global doc timeline: its metadata plus every doc file it
changed (under
docs_prefix), diffed against its first parent. - Revision
Content - One revision of a doc: its commit metadata plus the file content at this
revision (
new_text) and at its first parent (old_text).
Functions§
- discover_
repo - Open the repo that contains
path(walking up). ReturnsOk(None)whenpathis not inside any git repo — the graceful “not a git repo” path. - doc_
revisions - All commits (newest-first, capped at
limit) that toucheddoc_rel_path, each paired with the file content at that revision and at its first parent. - global_
doc_ revisions - All commits (newest-first, capped at
limitdoc-touching commits) that changed any file underdocs_prefix(repo-relative, e.g."docs"), each paired with the per-file old/new content from its first parent. The global analogue ofdoc_revisions— mirrorsgit log -- <docsPath>plus the per-commitgit diffin the originalgit-diff.server.ts. - head_
source - The content of a doc at git HEAD, for the editor’s merge-against-HEAD view.
docs_diris the absolute docs directory;doc_rel_pathis docs-relative (e.g."guide/intro.md"). ReturnsNoneoutside a repo, for an untracked file, or on any read error — the editor then shows no merge gutter.