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

Method StoreData

repository/gogit.go:503–523  ·  view source on GitHub ↗

StoreData will store arbitrary data and return the corresponding hash

(data []byte)

Source from the content-addressed store, hash-verified

501
502// StoreData will store arbitrary data and return the corresponding hash
503func (repo *GoGitRepo) StoreData(data []byte) (Hash, error) {
504 obj := repo.r.Storer.NewEncodedObject()
505 obj.SetType(plumbing.BlobObject)
506
507 w, err := obj.Writer()
508 if err != nil {
509 return "", err
510 }
511
512 _, err = w.Write(data)
513 if err != nil {
514 return "", err
515 }
516
517 h, err := repo.r.Storer.SetEncodedObject(obj)
518 if err != nil {
519 return "", err
520 }
521
522 return Hash(h.String()), nil
523}
524
525// ReadData will attempt to read arbitrary data from the given hash
526func (repo *GoGitRepo) ReadData(hash Hash) ([]byte, error) {

Callers

nothing calls this directly

Calls 3

HashTypeAlias · 0.85
StringMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected