Replace isGoodHash with more general isGoodCommit

This commit is contained in:
Solipsis
2023-03-20 17:16:19 -07:00
parent 4d1a26172e
commit abbe35e9eb
2 changed files with 6 additions and 6 deletions

View File

@@ -146,7 +146,7 @@ func (ddb *DoltDB) CSMetricsSummary() string {
// a proposed commit is acceptable.
type CommitMetaGenerator interface {
next() (*datas.CommitMeta, error)
isGoodHash(hash.Hash) bool
isGoodCommit(*datas.Commit) bool
}
// The default implementation of CommitMetaGenerator, which generates a single commit which is always acceptable.
@@ -160,7 +160,7 @@ func (g simpleCommitMetaGenerator) next() (*datas.CommitMeta, error) {
return datas.NewCommitMetaWithUserTS(g.name, g.email, g.message, g.timestamp)
}
func (simpleCommitMetaGenerator) isGoodHash(hash.Hash) bool {
func (simpleCommitMetaGenerator) isGoodCommit(*datas.Commit) bool {
return true
}
@@ -238,7 +238,7 @@ func (ddb *DoltDB) WriteEmptyRepoWithCommitMetaAndDefaultBranch(
return err
}
if !commitMetaGenerator.isGoodHash(firstCommit.Addr()) {
if !commitMetaGenerator.isGoodCommit(firstCommit) {
break
}
}

View File

@@ -20,9 +20,9 @@ import (
"time"
"github.com/dolthub/dolt/go/store/datas"
"github.com/dolthub/dolt/go/store/hash"
)
// An alternate implementation of CommitMetaGenerator, which only produces hashes which begin with "d0lt" or similar.
type funHashCommitMetaGenerator struct {
name, email string
timestamp time.Time
@@ -68,9 +68,9 @@ func (g funHashCommitMetaGenerator) next() (*datas.CommitMeta, error) {
return datas.NewCommitMetaWithUserTS(g.name, g.email, description, g.timestamp)
}
func (g funHashCommitMetaGenerator) isGoodHash(h hash.Hash) bool {
func (g funHashCommitMetaGenerator) isGoodCommit(commit *datas.Commit) bool {
var funRegExp = regexp.MustCompile("^d[o0][1l]t")
hashString := h.String()
hashString := commit.Addr().String()
return funRegExp.MatchString(hashString)
}