| Index: go/src/infra/libs/git/blob.go
|
| diff --git a/go/src/infra/libs/git/blob.go b/go/src/infra/libs/git/blob.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cf7fb3b4da3ac4d2e8df5f766970fbb916f65ce1
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/blob.go
|
| @@ -0,0 +1,40 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package git
|
| +
|
| +import (
|
| + "fmt"
|
| +)
|
| +
|
| +// Types ///////////////////////////////////////////////////////////////////////
|
| +
|
| +// Blob is a git Object which represents file data
|
| +type Blob struct {
|
| + id *ObjectID
|
| + data string
|
| +}
|
| +
|
| +// Constructors ///////////////////////////////////////////////////////////////
|
| +
|
| +// NewBlobFromRaw creates a new *Blob, calculating the ID() from |data|
|
| +func NewBlobFromRaw(data []byte) *Blob {
|
| + return NewBlobFromRawWithID(MakeObjectIDForData(BlobType, data), data)
|
| +}
|
| +
|
| +// BlobFromRawWithID creates a new *Blob, trusting |id|. There is no
|
| +// verification that |data| and |id| match.
|
| +func NewBlobFromRawWithID(id Identifiable, data []byte) *Blob {
|
| + return &Blob{id.ID(), string(data)}
|
| +}
|
| +
|
| +// Member functions ////////////////////////////////////////////////////////////
|
| +
|
| +func (b *Blob) ID() *ObjectID { return b.id }
|
| +func (b *Blob) Type() ObjectType { return BlobType }
|
| +func (b *Blob) Complete() bool { return true }
|
| +func (b *Blob) RawString() string { return b.data }
|
| +func (b *Blob) String() string {
|
| + return fmt.Sprintf("Blob(%s, <data len(%d)>)", b.ID(), len(b.data))
|
| +}
|
|
|