dolt commit -a ignores new tables

This commit is contained in:
Tan Yong Zhi
2022-08-20 21:29:11 +08:00
parent e5eb896147
commit 9dcb0359a7
2 changed files with 18 additions and 1 deletions

View File

@@ -103,7 +103,7 @@ func performCommit(ctx context.Context, commandStr string, args []string, dEnv *
}
if allFlag {
roots, err = actions.StageAllTables(ctx, roots)
roots, err = actions.StageModifiedAndDeletedTables(ctx, roots)
if err != nil {
return handleCommitErr(ctx, dEnv, err, help)
}

View File

@@ -17,6 +17,7 @@ package actions
import (
"context"
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
)
@@ -33,6 +34,22 @@ func StageAllTables(ctx context.Context, roots doltdb.Roots) (doltdb.Roots, erro
return stageTables(ctx, roots, tbls)
}
func StageModifiedAndDeletedTables(ctx context.Context, roots doltdb.Roots) (doltdb.Roots, error) {
_, unstaged, err := diff.GetStagedUnstagedTableDeltas(ctx, roots)
if err != nil {
return nil, err
}
tbls := []string{}
for _, tableDelta := range unstaged {
if !tableDelta.IsAdd() {
tbls = append(tbls, tableDelta.FromName)
}
}
return stageTables(ctx, roots, tbls)
}
func stageTables(
ctx context.Context,
roots doltdb.Roots,