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

Method MergeAll

cache/subcache.go:536–579  ·  view source on GitHub ↗
(remote string)

Source from the content-addressed store, hash-verified

534}
535
536func (sc *SubCache[EntityT, ExcerptT, CacheT]) MergeAll(remote string) <-chan entity.MergeResult {
537 out := make(chan entity.MergeResult)
538
539 // Intercept merge results to update the cache properly
540 go func() {
541 defer close(out)
542
543 author, err := sc.getUserIdentity()
544 if err != nil {
545 out <- entity.NewMergeError(err, "")
546 return
547 }
548
549 results := sc.actions.MergeAll(sc.repo, sc.resolvers(), remote, author)
550 for result := range results {
551 out <- result
552
553 if result.Err != nil {
554 continue
555 }
556
557 switch result.Status {
558 case entity.MergeStatusNew, entity.MergeStatusUpdated:
559 e := result.Entity.(EntityT)
560 cached := sc.makeCached(e, sc.entityUpdated)
561
562 sc.mu.Lock()
563 sc.excerpts[result.Id] = sc.makeExcerpt(cached)
564 // might as well keep them in memory
565 sc.cached[result.Id] = cached
566 sc.mu.Unlock()
567 }
568 }
569
570 err = sc.write()
571 if err != nil {
572 out <- entity.NewMergeError(err, "")
573 return
574 }
575 }()
576
577 return out
578
579}
580
581func (sc *SubCache[EntityT, ExcerptT, CacheT]) GetNamespace() string {
582 return sc.namespace

Callers

nothing calls this directly

Calls 5

writeMethod · 0.95
NewMergeErrorFunction · 0.92
closeFunction · 0.85
MergeAllMethod · 0.65
LockMethod · 0.65

Tested by

no test coverage detected