diff --git a/go/cmd/dolt/commands/init.go b/go/cmd/dolt/commands/init.go index 3c84160ca4..76aa819e36 100644 --- a/go/cmd/dolt/commands/init.go +++ b/go/cmd/dolt/commands/init.go @@ -159,7 +159,7 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d if requiresFunHash { return doltdb.MakeCommitMetaGenerator(name, email, t) } else { - return doltdb.FunHashCommitMetaGenerator{Name: name, Email: email, Timestamp: t} + return doltdb.MakeFunCommitMetaGenerator(name, email, t) } }() diff --git a/go/libraries/doltcore/doltdb/doltdb.go b/go/libraries/doltcore/doltdb/doltdb.go index 153f4c9067..c3987cfcaf 100644 --- a/go/libraries/doltcore/doltdb/doltdb.go +++ b/go/libraries/doltcore/doltdb/doltdb.go @@ -153,25 +153,25 @@ func (ddb *DoltDB) WriteEmptyRepoWithCommitMeta(ctx context.Context, initBranch } type CommitMetaGenerator interface { - Next() (*datas.CommitMeta, error) - IsGoodHash(hash.Hash) bool + next() (*datas.CommitMeta, error) + isGoodHash(hash.Hash) bool } func MakeCommitMetaGenerator(name, email string, timestamp time.Time) CommitMetaGenerator { - return SimpleCommitMetaGenerator{Name: name, Email: email, Timestamp: timestamp, Message: defaultInitialCommitMessage} + return simpleCommitMetaGenerator{name: name, email: email, timestamp: timestamp, message: defaultInitialCommitMessage} } -type SimpleCommitMetaGenerator struct { - Name, Email string - Timestamp time.Time - Message string +type simpleCommitMetaGenerator struct { + name, email string + timestamp time.Time + message string } -func (g SimpleCommitMetaGenerator) Next() (*datas.CommitMeta, error) { - return datas.NewCommitMetaWithUserTS(g.Name, g.Email, g.Message, g.Timestamp) +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) isGoodHash(hash.Hash) bool { return true } @@ -217,7 +217,7 @@ func (ddb *DoltDB) WriteEmptyRepoWithCommitMetaAndDefaultBranch( // the timestamp. var firstCommit *datas.Commit for { - cm, err := commitMetaGenerator.Next() + cm, err := commitMetaGenerator.next() if err != nil { return err } @@ -235,7 +235,7 @@ func (ddb *DoltDB) WriteEmptyRepoWithCommitMetaAndDefaultBranch( return err } - if !commitMetaGenerator.IsGoodHash(firstCommit.Addr()) { + if !commitMetaGenerator.isGoodHash(firstCommit.Addr()) { break } } diff --git a/go/libraries/doltcore/doltdb/fun_commit_hash.go b/go/libraries/doltcore/doltdb/fun_commit_hash.go index 6fd03516e5..3889705a4f 100644 --- a/go/libraries/doltcore/doltdb/fun_commit_hash.go +++ b/go/libraries/doltcore/doltdb/fun_commit_hash.go @@ -23,12 +23,16 @@ import ( "github.com/dolthub/dolt/go/store/hash" ) -type FunHashCommitMetaGenerator struct { - Name, Email string - Timestamp time.Time +type funHashCommitMetaGenerator struct { + name, email string + timestamp time.Time attempt int } +func MakeFunCommitMetaGenerator(name, email string, timestamp time.Time) CommitMetaGenerator { + return funHashCommitMetaGenerator{name: name, email: email, timestamp: timestamp, attempt: 0} +} + var descriptionReplacementCandidates = [][]rune{ {'I', '\u0406'}, {'i', '\u0456'}, @@ -44,11 +48,11 @@ var descriptionReplacementCandidates = [][]rune{ {'o', '\u043e'}, } -func (g FunHashCommitMetaGenerator) Next() (*datas.CommitMeta, error) { +func (g funHashCommitMetaGenerator) next() (*datas.CommitMeta, error) { if g.attempt >= 1<