Skip to main content

Module history

Module history 

Source
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§

CommitMeta
Commit metadata captured for a revision.
GlobalFileChange
One changed doc file within a single commit (the new side, plus its old content from the first parent). The global analogue of the per-file RevisionContent.
GlobalRevision
One commit in the global doc timeline: its metadata plus every doc file it changed (under docs_prefix), diffed against its first parent.
RevisionContent
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). Returns Ok(None) when path is not inside any git repo — the graceful “not a git repo” path.
doc_revisions
All commits (newest-first, capped at limit) that touched doc_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 limit doc-touching commits) that changed any file under docs_prefix (repo-relative, e.g. "docs"), each paired with the per-file old/new content from its first parent. The global analogue of doc_revisions — mirrors git log -- <docsPath> plus the per-commit git diff in the original git-diff.server.ts.
head_source
The content of a doc at git HEAD, for the editor’s merge-against-HEAD view. docs_dir is the absolute docs directory; doc_rel_path is docs-relative (e.g. "guide/intro.md"). Returns None outside a repo, for an untracked file, or on any read error — the editor then shows no merge gutter.