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

Method Write

entities/identity/version.go:222–243  ·  view source on GitHub ↗

Write will serialize and store the version as a git blob and return its hash

(repo repository.Repo)

Source from the content-addressed store, hash-verified

220// Write will serialize and store the version as a git blob and return
221// its hash
222func (v *version) Write(repo repository.Repo) (repository.Hash, error) {
223 // make sure we don't write invalid data
224 err := v.Validate()
225 if err != nil {
226 return "", errors.Wrap(err, "validation error")
227 }
228
229 data, err := json.Marshal(v)
230 if err != nil {
231 return "", err
232 }
233
234 hash, err := repo.StoreData(data)
235 if err != nil {
236 return "", err
237 }
238
239 // make sure we set the Id when writing in the repo
240 v.id = entity.DeriveId(data)
241
242 return hash, nil
243}
244
245func makeNonce(len int) []byte {
246 result := make([]byte, len)

Callers 15

writeMethod · 0.45
lockMethod · 0.45
IDMethod · 0.45
IDMethod · 0.45
IDMethod · 0.45
SelectFunction · 0.45
FromFileFunction · 0.45
StoreSignedCommitMethod · 0.45
MarshalGQLMethod · 0.45
RepoStorageTestFunction · 0.45
StoreDataMethod · 0.45
CommitMethod · 0.45

Calls 3

ValidateMethod · 0.95
DeriveIdFunction · 0.92
StoreDataMethod · 0.65

Tested by 1

TestGitFileHandlersFunction · 0.36