本文整理匯總了Golang中gopkg/in/src-d/go-git/v4/plumbing.EncodedObject.SetType方法的典型用法代碼示例。如果您正苦於以下問題:Golang EncodedObject.SetType方法的具體用法?Golang EncodedObject.SetType怎麽用?Golang EncodedObject.SetType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gopkg/in/src-d/go-git/v4/plumbing.EncodedObject
的用法示例。
在下文中一共展示了EncodedObject.SetType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Encode
// Encode transforms a Tag into a plumbing.EncodedObject.
func (t *Tag) Encode(o plumbing.EncodedObject) error {
o.SetType(plumbing.TagObject)
w, err := o.Writer()
if err != nil {
return err
}
defer ioutil.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
}
示例2: Encode
// Encode transforms a Commit into a plumbing.EncodedObject.
func (b *Commit) Encode(o plumbing.EncodedObject) error {
o.SetType(plumbing.CommitObject)
w, err := o.Writer()
if err != nil {
return err
}
defer ioutil.CheckClose(w, &err)
if _, err = fmt.Fprintf(w, "tree %s\n", b.tree.String()); err != nil {
return err
}
for _, parent := range b.parents {
if _, err = fmt.Fprintf(w, "parent %s\n", parent.String()); err != nil {
return err
}
}
if _, err = fmt.Fprint(w, "author "); err != nil {
return err
}
if err = b.Author.Encode(w); err != nil {
return err
}
if _, err = fmt.Fprint(w, "\ncommitter "); err != nil {
return err
}
if err = b.Committer.Encode(w); err != nil {
return err
}
if _, err = fmt.Fprintf(w, "\n\n%s", b.Message); err != nil {
return err
}
return err
}
示例3: Encode
// Encode transforms a Tree into a plumbing.EncodedObject.
func (t *Tree) Encode(o plumbing.EncodedObject) error {
o.SetType(plumbing.TreeObject)
w, err := o.Writer()
if err != nil {
return err
}
var size int
defer ioutil.CheckClose(w, &err)
for _, entry := range t.Entries {
n, err := fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name)
if err != nil {
return err
}
size += n
n, err = w.Write([]byte{0x00})
if err != nil {
return err
}
size += n
n, err = w.Write([]byte(entry.Hash[:]))
if err != nil {
return err
}
size += n
}
o.SetSize(int64(size))
return err
}
示例4: fillOFSDeltaObjectContent
func (d *Decoder) fillOFSDeltaObjectContent(obj plumbing.EncodedObject, 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())
}
示例5: Encode
// Encode transforms a Blob into a plumbing.EncodedObject.
func (b *Blob) Encode(o plumbing.EncodedObject) error {
w, err := o.Writer()
if err != nil {
return err
}
defer ioutil.CheckClose(w, &err)
r, err := b.Reader()
if err != nil {
return err
}
defer ioutil.CheckClose(r, &err)
_, err = io.Copy(w, r)
o.SetType(plumbing.BlobObject)
return err
}