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..fde92ecc4b72fa448c81c9edfb3d0a0d8f914058 |
| --- /dev/null |
| +++ b/go/src/infra/libs/git/blob.go |
| @@ -0,0 +1,26 @@ |
| +// 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 |
|
M-A Ruel
2014/10/21 00:55:53
you need to keep an empty line, otherwise it is co
iannucci
2016/05/23 21:53:42
oh, yikes, ok
|
| + |
| +// Blob is a git Object which represents file data |
| +type Blob struct { |
| + id ObjectID |
| + data string |
|
M-A Ruel
2014/10/21 00:55:53
So you really use string here as []byte. I think I
iannucci
2016/05/23 21:53:42
Well... most blobs /are/ human readable (usually t
|
| +} |
| + |
| +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 } |
| + |
| +// BlobFromRaw creates a new *Blob, calculating the ID() from |data| |
| +func BlobFromRaw(data []byte) *Blob { |
| + return BlobFromRawWithID(MakeObjectIDForData(BlobType, data), data) |
| +} |
| + |
| +// BlobFromRawWithID creates a new *Blob, trusting |id|. There is no verification |
|
M-A Ruel
2014/10/21 00:55:53
Generally I personally ensure these docstrings are
iannucci
2016/05/23 21:53:42
Done.
|
| +// that |data| and |id| match. |
| +func BlobFromRawWithID(id ObjectID, data []byte) *Blob { |
| + return &Blob{id, string(data)} |
| +} |