MCPcopy Index your code
hub / github.com/git-bug/git-bug / NewRepoCacheBug

Function NewRepoCacheBug

cache/bug_subcache.go:20–54  ·  view source on GitHub ↗
(repo repository.ClockedRepo,
	resolvers func() entity.Resolvers,
	getUserIdentity getUserIdentityFunc)

Source from the content-addressed store, hash-verified

18}
19
20func NewRepoCacheBug(repo repository.ClockedRepo,
21 resolvers func() entity.Resolvers,
22 getUserIdentity getUserIdentityFunc) *RepoCacheBug {
23
24 makeCached := func(b *bug.Bug, entityUpdated func(id entity.Id) error) *BugCache {
25 return NewBugCache(b, repo, getUserIdentity, entityUpdated)
26 }
27
28 makeIndexData := func(b *BugCache) []string {
29 snap := b.Snapshot()
30 var res []string
31 for _, comment := range snap.Comments {
32 res = append(res, comment.Message)
33 }
34 res = append(res, snap.Title)
35 return res
36 }
37
38 actions := Actions[*bug.Bug]{
39 ReadWithResolver: bug.ReadWithResolver,
40 ReadAllWithResolver: bug.ReadAllWithResolver,
41 Remove: bug.Remove,
42 RemoveAll: bug.RemoveAll,
43 MergeAll: bug.MergeAll,
44 }
45
46 sc := NewSubCache[*bug.Bug, *BugExcerpt, *BugCache](
47 repo, resolvers, getUserIdentity,
48 makeCached, NewBugExcerpt, makeIndexData, actions,
49 bug.Typename, bug.Namespace,
50 formatVersion, defaultMaxLoadedBugs,
51 )
52
53 return &RepoCacheBug{SubCache: sc}
54}
55
56// ResolveBugCreateMetadata retrieve a bug that has the exact given metadata on
57// its Create operation, that is, the first operation. It fails if multiple bugs

Callers 1

NewNamedRepoCacheFunction · 0.85

Calls 3

NewBugCacheFunction · 0.85
NewSubCacheFunction · 0.85
SnapshotMethod · 0.80

Tested by

no test coverage detected