Add HasHead function to dataset (#3262)

This commit is contained in:
Dan Willhite
2017-03-08 18:29:12 -08:00
committed by GitHub
parent 699c48cefa
commit 1e9bb40c44
2 changed files with 7 additions and 0 deletions

View File

@@ -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 {

View File

@@ -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)