// Encode transforms a Tag into a plumbing.Object. func (t *Tag) Encode(o plumbing.Object) error { o.SetType(plumbing.TagObject) w, err := o.Writer() if err != nil { return err } defer checkClose(w, &err) if _, err = fmt.Fprintf(w, "object %s\ntype %s\ntag %s\ntagger ", t.Target.String(), t.TargetType.Bytes(), t.Name); err != nil { return err } if err = t.Tagger.Encode(w); err != nil { return err } if _, err = fmt.Fprint(w, "\n\n"); err != nil { return err } if _, err = fmt.Fprint(w, t.Message); err != nil { return err } return err }
func (d *Decoder) fillOFSDeltaObjectContent(obj plumbing.Object, offset int64) (uint32, error) { buf := bytes.NewBuffer(nil) _, crc, err := d.s.NextObject(buf) if err != nil { return 0, err } base, err := d.recallByOffset(offset) if err != nil { return 0, err } obj.SetType(base.Type()) return crc, ApplyDelta(obj, base, buf.Bytes()) }
// Encode transforms a Blob into a plumbing.Object. func (b *Blob) Encode(o plumbing.Object) error { w, err := o.Writer() if err != nil { return err } defer checkClose(w, &err) r, err := b.Reader() if err != nil { return err } defer checkClose(r, &err) _, err = io.Copy(w, r) o.SetType(plumbing.BlobObject) return err }