MCPcopy Create free account
hub / github.com/git-bug/git-bug / IdOperation

Function IdOperation

entity/dag/operation.go:137–156  ·  view source on GitHub ↗
(op Operation, base *OpBase)

Source from the content-addressed store, hash-verified

135}
136
137func IdOperation(op Operation, base *OpBase) entity.Id {
138 if base.id == "" {
139 // something went really wrong
140 panic("op's id not set")
141 }
142 if base.id == entity.UnsetId {
143 // This means we are trying to get the op's Id *before* it has been stored, for instance when
144 // adding multiple ops in one go in an OperationPack.
145 // As the Id is computed based on the actual bytes written on the disk, we are going to predict
146 // those and then get the Id. This is safe as it will be the exact same code writing on disk later.
147
148 data, err := json.Marshal(op)
149 if err != nil {
150 panic(err)
151 }
152
153 base.id = entity.DeriveId(data)
154 }
155 return base.id
156}
157
158func (base *OpBase) Type() OperationType {
159 return base.OperationType

Callers 13

IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.92
IdMethod · 0.85
IdMethod · 0.85
IdMethod · 0.85

Calls 1

DeriveIdFunction · 0.92

Tested by 5

IdMethod · 0.74
IdMethod · 0.74
IdMethod · 0.74
IdMethod · 0.68
IdMethod · 0.68