mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-20 18:19:15 -06:00
Reorder doltdb.go for readability.
This commit is contained in:
@@ -140,27 +140,11 @@ func (ddb *DoltDB) CSMetricsSummary() string {
|
||||
return datas.GetCSStatSummaryForDB(ddb.db)
|
||||
}
|
||||
|
||||
// WriteEmptyRepo will create initialize the given db with a master branch which points to a commit which has valid
|
||||
// metadata for the creation commit, and an empty RootValue.
|
||||
func (ddb *DoltDB) WriteEmptyRepo(ctx context.Context, initBranch, name, email string) error {
|
||||
return ddb.WriteEmptyRepoWithCommitMeta(ctx, initBranch, MakeCommitMetaGenerator(name, email, datas.CommitNowFunc()))
|
||||
}
|
||||
|
||||
const defaultInitialCommitMessage = "Initialize data repository"
|
||||
|
||||
func (ddb *DoltDB) WriteEmptyRepoWithCommitMeta(ctx context.Context, initBranch string, commitMeta CommitMetaGenerator) error {
|
||||
return ddb.WriteEmptyRepoWithCommitMetaAndDefaultBranch(ctx, commitMeta, ref.NewBranchRef(initBranch))
|
||||
}
|
||||
|
||||
type CommitMetaGenerator interface {
|
||||
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}
|
||||
}
|
||||
|
||||
type simpleCommitMetaGenerator struct {
|
||||
name, email string
|
||||
timestamp time.Time
|
||||
@@ -175,6 +159,22 @@ func (simpleCommitMetaGenerator) isGoodHash(hash.Hash) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
const defaultInitialCommitMessage = "Initialize data repository"
|
||||
|
||||
func MakeCommitMetaGenerator(name, email string, timestamp time.Time) CommitMetaGenerator {
|
||||
return simpleCommitMetaGenerator{name: name, email: email, timestamp: timestamp, message: defaultInitialCommitMessage}
|
||||
}
|
||||
|
||||
// WriteEmptyRepo will create initialize the given db with a master branch which points to a commit which has valid
|
||||
// metadata for the creation commit, and an empty RootValue.
|
||||
func (ddb *DoltDB) WriteEmptyRepo(ctx context.Context, initBranch, name, email string) error {
|
||||
return ddb.WriteEmptyRepoWithCommitMeta(ctx, initBranch, MakeCommitMetaGenerator(name, email, datas.CommitNowFunc()))
|
||||
}
|
||||
|
||||
func (ddb *DoltDB) WriteEmptyRepoWithCommitMeta(ctx context.Context, initBranch string, commitMeta CommitMetaGenerator) error {
|
||||
return ddb.WriteEmptyRepoWithCommitMetaAndDefaultBranch(ctx, commitMeta, ref.NewBranchRef(initBranch))
|
||||
}
|
||||
|
||||
func (ddb *DoltDB) WriteEmptyRepoWithCommitTimeAndDefaultBranch(
|
||||
ctx context.Context,
|
||||
name, email string,
|
||||
|
||||
Reference in New Issue
Block a user