| Index: go/src/infra/libs/git/mode.go
|
| diff --git a/go/src/infra/libs/git/mode.go b/go/src/infra/libs/git/mode.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a13748c580f9b25fa0be115e9832a0a73d7bc36f
|
| --- /dev/null
|
| +++ b/go/src/infra/libs/git/mode.go
|
| @@ -0,0 +1,32 @@
|
| +// 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 ///////////////////////////////////////////////////////////////////////
|
| +
|
| +// Mode is a typed representation of git's tree mode concept
|
| +type Mode int
|
| +
|
| +// Member functions ////////////////////////////////////////////////////////////
|
| +
|
| +// Type returns a Object.Type() compatible string for this mode.
|
| +func (m Mode) Type() ObjectType {
|
| + switch {
|
| + case m == 0040000:
|
| + return TreeType
|
| + case m == 0160000:
|
| + return CommitType
|
| + case (m & 0100000) != 0:
|
| + return BlobType
|
| + default:
|
| + return UnknownType
|
| + }
|
| +}
|
| +
|
| +func (m Mode) String() string { return fmt.Sprintf("%06o", m) }
|
|
|