6 "github.com/aymanbagabas/go-udiff"
9// GenerateDiff creates a unified diff from two file contents
10func GenerateDiff(beforeContent, afterContent, fileName string) (string, int, int) {
11 fileName = strings.TrimPrefix(fileName, "/")
14 unified = udiff.Unified("a/"+fileName, "b/"+fileName, beforeContent, afterContent)
19 lines := strings.SplitSeq(unified, "\n")
20 for line := range lines {
21 if strings.HasPrefix(line, "+") && !strings.HasPrefix(line, "+++") {
23 } else if strings.HasPrefix(line, "-") && !strings.HasPrefix(line, "---") {
28 return unified, additions, removals
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list