Chromium Code Reviews| 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..954c46290581ca61bcbc2a6807cf2e3e0f3ff162 |
| --- /dev/null |
| +++ b/go/src/infra/libs/git/blob.go |
| @@ -0,0 +1,23 @@ |
| +package git |
|
M-A Ruel
2014/10/18 00:47:04
Chromium Copyright.
iannucci
2014/10/20 21:11:56
Done.
|
| + |
| +// Blob is a git Object which represents file data |
| +type Blob struct { |
| + id ObjectID |
| + data string |
| +} |
| + |
| +func (b *Blob) ID() ObjectID { return b.id } |
| +func (b *Blob) Type() string { return "blob" } |
| +func (b *Blob) Complete() bool { return true } |
| +func (b *Blob) RawString() string { return b.data } |
| + |
| +// BlobFromRaw creates a new *Blob, calculating the ID() from |data| |
| +func BlobFromRaw(data []byte) *Blob { |
| + return BlobFromRawWithID(MakeObjectIDForData("blob", data), data) |
| +} |
| + |
| +// BlobFromRawWithID creates a new *Blob, trusting |id|. There is no verification |
| +// that |data| and |id| match. |
| +func BlobFromRawWithID(id ObjectID, data []byte) *Blob { |
| + return &Blob{id, string(data)} |
| +} |