| Index: go/src/infra/libs/git/objectType.go
|
| diff --git a/go/src/infra/libs/git/objectType.go b/go/src/infra/libs/git/objectType.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..093239fc766b96e90d7b21d98b87b356aa57d469
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/objectType.go
|
| @@ -0,0 +1,57 @@
|
| +// 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 ///////////////////////////////////////////////////////////////////////
|
| +
|
| +type ObjectType uint8
|
| +
|
| +// Constants ///////////////////////////////////////////////////////////////////
|
| +
|
| +const (
|
| + UnknownType ObjectType = iota
|
| + CommitType
|
| + BlobType
|
| + TreeType
|
| + TagType
|
| +)
|
| +
|
| +// Constructors ///////////////////////////////////////////////////////////////
|
| +
|
| +func MakeObjectType(s string) ObjectType {
|
| + switch s {
|
| + case "commit":
|
| + return CommitType
|
| + case "blob":
|
| + return BlobType
|
| + case "tree":
|
| + return TreeType
|
| + case "tag":
|
| + return TagType
|
| + default:
|
| + panic(fmt.Errorf("unknown object type %s", s))
|
| + }
|
| +}
|
| +
|
| +// Member functions ////////////////////////////////////////////////////////////
|
| +
|
| +func (o ObjectType) String() string {
|
| + switch o {
|
| + case CommitType:
|
| + return "commit"
|
| + case BlobType:
|
| + return "blob"
|
| + case TreeType:
|
| + return "tree"
|
| + case TagType:
|
| + return "tag"
|
| + default:
|
| + return "UNKNOWN"
|
| + }
|
| +}
|
|
|