Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: go/src/infra/libs/git/types.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/libs/git/tree_test.go ('k') | go/src/infra/libs/git/user.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
+}
« no previous file with comments | « go/src/infra/libs/git/tree_test.go ('k') | go/src/infra/libs/git/user.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698