mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-09 18:59:12 -06:00
58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
// Copyright 2016 Attic Labs, Inc. All rights reserved.
|
|
// Licensed under the Apache License, version 2.0:
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
package datas
|
|
|
|
import "github.com/attic-labs/noms/go/types"
|
|
|
|
var commitType *types.Type
|
|
var refOfCommitType *types.Type
|
|
|
|
const (
|
|
ParentsField = "parents"
|
|
ValueField = "value"
|
|
)
|
|
|
|
func init() {
|
|
// struct Commit {
|
|
// parents: Set<Ref<Commit>>
|
|
// value: Value
|
|
// }
|
|
|
|
commitType = types.MakeStructType("Commit",
|
|
[]string{ParentsField, ValueField},
|
|
[]*types.Type{
|
|
types.MakeSetType(types.MakeRefType(types.MakeCycleType(0))),
|
|
types.ValueType,
|
|
},
|
|
)
|
|
|
|
refOfCommitType = types.MakeRefType(commitType)
|
|
}
|
|
|
|
func NewCommit() types.Struct {
|
|
initialFields := types.ValueSlice{
|
|
types.NewSet(), // parents
|
|
types.String(""), // value
|
|
}
|
|
|
|
return types.NewStructWithType(commitType, initialFields)
|
|
}
|
|
|
|
func typeForMapOfStringToRefOfCommit() *types.Type {
|
|
return types.MakeMapType(types.StringType, refOfCommitType)
|
|
}
|
|
|
|
func NewMapOfStringToRefOfCommit() types.Map {
|
|
return types.NewMap()
|
|
}
|
|
|
|
func typeForSetOfRefOfCommit() *types.Type {
|
|
return types.MakeSetType(refOfCommitType)
|
|
}
|
|
|
|
func CommitType() *types.Type {
|
|
return commitType
|
|
}
|