Documentation
¶
Overview ¶
Package source produces raw git-diff patch bytes for the parser. Three flavors:
- FromCommit — commit-vs-parent (for the single-commit page)
- FromRange — base..head two-dot (for compare-style diffs)
- FromMergeBase — base...head three-dot (for PR / compare against the merge-base; matches GitHub's PR file-list behavior)
Each function returns the unified-diff bytes; the parser package consumes from there. Whitespace-ignoring requested via Options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromCommit ¶
FromCommit returns the diff between sha and its first parent. For a root commit (no parent) we diff against the empty tree by using `git diff-tree -p -r --root`.
func FromMergeBase ¶
FromMergeBase returns the three-dot diff base...head. Equivalent to `git diff $(git merge-base base head)..head`. Used by PR / compare pages — shows only what `head` adds over the common ancestor.
Types ¶
type Options ¶
type Options struct {
IgnoreWhitespace bool
// FindRenames toggles -M (--find-renames). Default off matches
// historical git behavior; the package's helpers turn it on for
// the rendered surfaces because rename detection is what users
// expect on a code-review page.
FindRenames bool
}
Options tunes a diff source. IgnoreWhitespace passes -w to git so whitespace-only lines vanish from the patch (cleaner UX than parser- side filtering, and git's whitespace handling respects language quirks like indentation-sensitive Python).