MCPcopy Index your code
hub / github.com/MiniCodeMonkey/chief / loadDiff

Method loadDiff

internal/tui/diff.go:72–113  ·  view source on GitHub ↗

loadDiff loads a diff, either for a specific commit or the full branch.

(storyID, commitHash string)

Source from the content-addressed store, hash-verified

70
71// loadDiff loads a diff, either for a specific commit or the full branch.
72func (d *DiffViewer) loadDiff(storyID, commitHash string) {
73 d.offset = 0
74 d.loaded = true
75
76 var diff string
77 var err error
78
79 if commitHash != "" {
80 diff, err = git.GetDiffForCommit(d.baseDir, commitHash)
81 } else {
82 diff, err = git.GetDiff(d.baseDir)
83 }
84
85 if err != nil {
86 d.err = err
87 d.lines = nil
88 d.stats = ""
89 return
90 }
91
92 d.err = nil
93
94 if strings.TrimSpace(diff) == "" {
95 d.lines = nil
96 d.stats = ""
97 return
98 }
99
100 d.lines = strings.Split(diff, "\n")
101
102 if commitHash != "" {
103 stats, err := git.GetDiffStatsForCommit(d.baseDir, commitHash)
104 if err == nil {
105 d.stats = stats
106 }
107 } else {
108 stats, err := git.GetDiffStats(d.baseDir)
109 if err == nil {
110 d.stats = stats
111 }
112 }
113}
114
115// ScrollUp scrolls up one line.
116func (d *DiffViewer) ScrollUp() {

Callers 2

LoadMethod · 0.95
LoadForStoryMethod · 0.95

Calls 4

GetDiffForCommitFunction · 0.92
GetDiffFunction · 0.92
GetDiffStatsForCommitFunction · 0.92
GetDiffStatsFunction · 0.92

Tested by

no test coverage detected