From abbe35e9eb8daaa7da7ada001cd5df2489f17e9c Mon Sep 17 00:00:00 2001 From: Solipsis Date: Mon, 20 Mar 2023 17:16:19 -0700 Subject: [PATCH] Replace isGoodHash with more general isGoodCommit --- go/libraries/doltcore/doltdb/doltdb.go | 6 +++--- go/libraries/doltcore/doltdb/fun_commit_hash.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/libraries/doltcore/doltdb/doltdb.go b/go/libraries/doltcore/doltdb/doltdb.go index 9d78d3301e..facc4b7d77 100644 --- a/go/libraries/doltcore/doltdb/doltdb.go +++ b/go/libraries/doltcore/doltdb/doltdb.go @@ -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 } } diff --git a/go/libraries/doltcore/doltdb/fun_commit_hash.go b/go/libraries/doltcore/doltdb/fun_commit_hash.go index 3889705a4f..78e61177bc 100644 --- a/go/libraries/doltcore/doltdb/fun_commit_hash.go +++ b/go/libraries/doltcore/doltdb/fun_commit_hash.go @@ -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) }