MCPcopy Create free account
hub / github.com/go-git/go-git / SetEncodedObject

Method SetEncodedObject

storage/memory/storage.go:97–115  ·  view source on GitHub ↗
(obj plumbing.EncodedObject)

Source from the content-addressed store, hash-verified

95}
96
97func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) {
98 h := obj.Hash()
99 o.Objects[h] = obj
100
101 switch obj.Type() {
102 case plumbing.CommitObject:
103 o.Commits[h] = o.Objects[h]
104 case plumbing.TreeObject:
105 o.Trees[h] = o.Objects[h]
106 case plumbing.BlobObject:
107 o.Blobs[h] = o.Objects[h]
108 case plumbing.TagObject:
109 o.Tags[h] = o.Objects[h]
110 default:
111 return h, ErrUnsupportedObjectType
112 }
113
114 return h, nil
115}
116
117func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) {
118 if _, ok := o.Objects[h]; !ok {

Callers

nothing calls this directly

Calls 2

HashMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected