| Index: go/src/infra/libs/git/types.go
|
| diff --git a/go/src/infra/libs/git/types.go b/go/src/infra/libs/git/types.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..6a6254fa59319fe4bee426f75eb48b94ee866df0
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/types.go
|
| @@ -0,0 +1,63 @@
|
| +// 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"
|
| +)
|
| +
|
| +// Interfaces //////////////////////////////////////////////////////////////////
|
| +
|
| +type Identifiable interface {
|
| + ID() *ObjectID
|
| +}
|
| +
|
| +// Object is the barest essence of a git object. It has a Type, and Id, and it
|
| +// can tell you if this instance is 'complete' (does it contain all the data
|
| +// necessary to re-create ID()?).
|
| +//
|
| +// If Complete() is true, you can down-cast this to:
|
| +// *Tree, *Blob, *Commit
|
| +//
|
| +// If Complete() is false, you can down-cast this to:
|
| +// *Tree, EmptyObject
|
| +//
|
| +// Note that Tree's are never EmptyObject's.
|
| +type Object interface {
|
| + Identifiable
|
| +
|
| + Type() ObjectType
|
| +
|
| + // Returns True iff RawString will produce a string which, when hashed,
|
| + // matches ID()
|
| + Complete() bool
|
| +}
|
| +
|
| +// InternableObject is an Object which may be interned into a git repo
|
| +// (e.g. hash-object'd). EmptyObjects are NOT InternableObjects.
|
| +type InternableObject interface {
|
| + fmt.Stringer
|
| + Object
|
| +
|
| + // A hash-object compatible string. May panic if this is an Object which is
|
| + // !Complete(). Note that for Trees this does NOT imply that all of the
|
| + // Tree's children are Complete().
|
| + RawString() string
|
| +}
|
| +
|
| +type GitService interface {
|
| + Intern(InternableObject) (*ObjectID, error)
|
| + HasObjectID(Identifiable) bool
|
| + GetObjectID(Identifiable) (InternableObject, error)
|
| + ObjectInfo(string) *ObjectInfo
|
| +}
|
| +
|
| +// Concrete Types //////////////////////////////////////////////////////////////
|
| +
|
| +type ObjectInfo struct {
|
| + Type ObjectType
|
| + Size int
|
| + ID *ObjectID
|
| +}
|
|
|