mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-20 10:09:03 -06:00
Replace isGoodHash with more general isGoodCommit
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user