MCPcopy
hub / github.com/rgburke/grv / OnCommitSelected

Method OnCommitSelected

cmd/grv/diff_view.go:352–372  ·  view source on GitHub ↗

OnCommitSelected loads/fetches the diff for the selected commit and refreshes the display

(commit *Commit)

Source from the content-addressed store, hash-verified

350
351// OnCommitSelected loads/fetches the diff for the selected commit and refreshes the display
352func (diffView *DiffView) OnCommitSelected(commit *Commit) (err error) {
353 log.Debugf("DiffView loading diff for selected commit %v", commit.commit.Id())
354
355 diffID := diffID(commit.oid.String())
356
357 diffView.lock.Lock()
358 diffView.lastRequestedDiff = diffID
359
360 if diffView.switchToDiffIfExists(diffID) {
361 diffView.lock.Unlock()
362 return
363 }
364
365 diffView.lock.Unlock()
366
367 diffView.addDiffLoadRequest(&commitDiffLoadRequest{
368 commit: commit,
369 })
370
371 return
372}
373
374func (diffView *DiffView) switchToDiffIfExists(diffID diffID) (exists bool) {
375 diffLines, exists := diffView.diffs[diffID]

Callers

nothing calls this directly

Calls 6

switchToDiffIfExistsMethod · 0.95
addDiffLoadRequestMethod · 0.95
diffIDTypeAlias · 0.85
StringMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected