mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-13 03:09:06 -06:00
Add HasHead function to dataset (#3262)
This commit is contained in:
@@ -64,6 +64,11 @@ func (ds Dataset) MaybeHeadRef() (types.Ref, bool) {
|
||||
return ds.headRef, ds.headRef != types.Ref{}
|
||||
}
|
||||
|
||||
// HasHead() returns 'true' if this dataset has a Head Commit, false otherwise.
|
||||
func (ds Dataset) HasHead() bool {
|
||||
return ds.headRef != types.Ref{}
|
||||
}
|
||||
|
||||
// HeadRef returns the Ref of the current head Commit, which contains the
|
||||
// current root of the Dataset's value tree.
|
||||
func (ds Dataset) HeadRef() types.Ref {
|
||||
|
||||
@@ -147,11 +147,13 @@ func TestHeadValueFunctions(t *testing.T) {
|
||||
defer store.Close()
|
||||
|
||||
ds1 := store.GetDataset(id1)
|
||||
assert.False(ds1.HasHead())
|
||||
|
||||
// ds1: |a|
|
||||
a := types.String("a")
|
||||
ds1, err := store.CommitValue(ds1, a)
|
||||
assert.NoError(err)
|
||||
assert.True(ds1.HasHead())
|
||||
|
||||
hv := ds1.Head().Get(ValueField)
|
||||
assert.Equal(a, hv)
|
||||
|
||||
Reference in New Issue
Block a user