mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-14 02:08:41 -05:00
Small refactoring to reduce env dependency
This commit is contained in:
@@ -193,7 +193,7 @@ func performCommit(ctx context.Context, commandStr string, args []string, dEnv *
|
||||
mergeParentCommits = parentsHeadForAmend
|
||||
}
|
||||
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, ws.MergeActive(), mergeParentCommits, dEnv.DbData(), actions.CommitStagedProps{
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, ws.MergeActive(), mergeParentCommits, dEnv.DbData().Ddb, actions.CommitStagedProps{
|
||||
Message: msg,
|
||||
Date: t,
|
||||
AllowEmpty: apr.Contains(cli.AllowEmptyFlag) || apr.Contains(cli.AmendFlag),
|
||||
|
||||
@@ -245,7 +245,7 @@ func (mr *MultiRepoTestSetup) CommitWithWorkingSet(dbName string) *doltdb.Commit
|
||||
if err != nil {
|
||||
panic("couldn't get roots: " + err.Error())
|
||||
}
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, ws.MergeActive(), mergeParentCommits, dEnv.DbData(), actions.CommitStagedProps{
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, ws.MergeActive(), mergeParentCommits, dEnv.DbData().Ddb, actions.CommitStagedProps{
|
||||
Message: "auto commit",
|
||||
Date: t,
|
||||
AllowEmpty: true,
|
||||
|
||||
10
go/libraries/doltcore/env/actions/commit.go
vendored
10
go/libraries/doltcore/env/actions/commit.go
vendored
@@ -130,19 +130,15 @@ func CommitStaged(ctx context.Context, roots doltdb.Roots, mergeActive bool, mer
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// GetCommitStaged adds a new commit to HEAD with the given props, returning it as a PendingCommit that can be
|
||||
// committed with doltdb.CommitWithWorkingSet
|
||||
// GetCommitStaged returns a new pending commit with the roots and commit properties given.
|
||||
func GetCommitStaged(
|
||||
ctx context.Context,
|
||||
roots doltdb.Roots,
|
||||
mergeActive bool,
|
||||
mergeParents []*doltdb.Commit,
|
||||
dbData env.DbData,
|
||||
db *doltdb.DoltDB,
|
||||
props CommitStagedProps,
|
||||
) (*doltdb.PendingCommit, error) {
|
||||
ddb := dbData.Ddb
|
||||
rsr := dbData.Rsr
|
||||
|
||||
if props.Message == "" {
|
||||
return nil, datas.ErrEmptyCommitMessage
|
||||
}
|
||||
@@ -194,5 +190,5 @@ func GetCommitStaged(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ddb.NewPendingCommit(ctx, roots, mergeParents, meta)
|
||||
return db.NewPendingCommit(ctx, roots, mergeParents, meta)
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ func (d *DoltSession) NewPendingCommit(ctx *sql.Context, dbName string, roots do
|
||||
mergeParentCommits = []*doltdb.Commit{sessionState.WorkingSet.MergeState().Commit()}
|
||||
}
|
||||
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, sessionState.WorkingSet.MergeActive(), mergeParentCommits, sessionState.dbData, props)
|
||||
pendingCommit, err := actions.GetCommitStaged(ctx, roots, sessionState.WorkingSet.MergeActive(), mergeParentCommits, sessionState.dbData.Ddb, props)
|
||||
if _, ok := err.(actions.NothingStaged); err != nil && !ok {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user