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

Method ResolveOperationWithMetadata

cache/cached.go:39–61  ·  view source on GitHub ↗

ResolveOperationWithMetadata will find an operation that has the matching metadata

(key string, value string)

Source from the content-addressed store, hash-verified

37
38// ResolveOperationWithMetadata will find an operation that has the matching metadata
39func (e *CachedEntityBase[SnapT, OpT]) ResolveOperationWithMetadata(key string, value string) (entity.Id, error) {
40 e.mu.RLock()
41 defer e.mu.RUnlock()
42 // preallocate but empty
43 matching := make([]entity.Id, 0, 5)
44
45 for _, op := range e.entity.Operations() {
46 opValue, ok := op.GetMetadata(key)
47 if ok && value == opValue {
48 matching = append(matching, op.Id())
49 }
50 }
51
52 if len(matching) == 0 {
53 return "", ErrNoMatchingOp
54 }
55
56 if len(matching) > 1 {
57 return "", entity.NewErrMultipleMatch("operation", matching)
58 }
59
60 return matching[0], nil
61}
62
63func (e *CachedEntityBase[SnapT, OpT]) Validate() error {
64 e.mu.RLock()

Callers 7

ensureTimelineItemMethod · 0.80
ensureCommentEditMethod · 0.80
ensureCommentMethod · 0.80
ImportAllMethod · 0.80
ensureIssueEventMethod · 0.80
ensureCommentMethod · 0.80
ensureChangeMethod · 0.80

Calls 4

NewErrMultipleMatchFunction · 0.92
OperationsMethod · 0.65
GetMetadataMethod · 0.65
IdMethod · 0.65

Tested by

no test coverage detected