mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-20 19:31:56 -05:00
All users of actions.StageTables and actions.StageAllTables specify whether to filter ignored tables.
Also add `--force` to `dolt add` and `--add-ignored` to `dolt commit`. Git uses `--force` for both, but we're already using `dolt commit --force` to mean something else.
This commit is contained in:
@@ -117,6 +117,7 @@ const (
|
||||
ListFlag = "list"
|
||||
UserParam = "user"
|
||||
NoPrettyFlag = "no-pretty"
|
||||
AddIgnoredFlag = "add-ignored"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -142,6 +143,7 @@ func CreateCommitArgParser() *argparser.ArgParser {
|
||||
ap.SupportsFlag(AllowEmptyFlag, "", "Allow recording a commit that has the exact same data as its sole parent. This is usually a mistake, so it is disabled by default. This option bypasses that safety.")
|
||||
ap.SupportsString(DateParam, "", "date", "Specify the date used in the commit. If not specified the current system time is used.")
|
||||
ap.SupportsFlag(ForceFlag, "f", "Ignores any foreign key warnings and proceeds with the commit.")
|
||||
ap.SupportsFlag(AddIgnoredFlag, "i", "Allow adding otherwise ignored files.")
|
||||
ap.SupportsString(AuthorParam, "", "author", "Specify an explicit author using the standard A U Thor {{.LessThan}}author@example.com{{.GreaterThan}} format.")
|
||||
ap.SupportsFlag(AllFlag, "a", "Adds all existing, changed tables (but not new tables) in the working set to the staged set.")
|
||||
ap.SupportsFlag(UpperCaseAllFlag, "A", "Adds all tables (including new tables) in the working set to the staged set.")
|
||||
@@ -183,7 +185,9 @@ func CreatePushArgParser() *argparser.ArgParser {
|
||||
func CreateAddArgParser() *argparser.ArgParser {
|
||||
ap := argparser.NewArgParserWithVariableArgs("add")
|
||||
ap.ArgListHelp = append(ap.ArgListHelp, [2]string{"table", "Working table(s) to add to the list tables staged to be committed. The abbreviation '.' can be used to add all tables."})
|
||||
ap.SupportsFlag(AllFlag, "A", "Stages any and all changes (adds, deletes, and modifications).")
|
||||
ap.SupportsFlag(AllFlag, "A", "Stages any and all changes (adds, deletes, and modifications) except for ignored tables.")
|
||||
ap.SupportsFlag(ForceFlag, "f", "Allow adding otherwise ignored tables.")
|
||||
|
||||
return ap
|
||||
}
|
||||
|
||||
|
||||
@@ -79,12 +79,12 @@ func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dE
|
||||
if apr.NArg() == 0 && !allFlag {
|
||||
cli.Println("Nothing specified, nothing added.\n Maybe you wanted to say 'dolt add .'?")
|
||||
} else if allFlag || apr.NArg() == 1 && apr.Arg(0) == "." {
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, !apr.Contains(cli.ForceFlag))
|
||||
if err != nil {
|
||||
return HandleStageError(err)
|
||||
}
|
||||
} else {
|
||||
roots, err = actions.StageTables(ctx, roots, apr.Args)
|
||||
roots, err = actions.StageTables(ctx, roots, apr.Args, !apr.Contains(cli.ForceFlag))
|
||||
if err != nil {
|
||||
return HandleStageError(err)
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func performCommit(ctx context.Context, commandStr string, args []string, dEnv *
|
||||
}
|
||||
|
||||
if upperCaseAllFlag {
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, !apr.Contains(cli.AddIgnoredFlag))
|
||||
if err != nil {
|
||||
return handleCommitErr(ctx, dEnv, err, help)
|
||||
}
|
||||
|
||||
@@ -179,7 +179,8 @@ func applyStashAtIdx(ctx context.Context, dEnv *env.DoltEnv, curWorkingRoot *dol
|
||||
}
|
||||
|
||||
// added tables need to be staged
|
||||
roots, err = actions.StageTables(ctx, roots, meta.TablesToStage)
|
||||
// since these tables are coming from a stash, don't filter for ignored table names.
|
||||
roots, err = actions.StageTables(ctx, roots, meta.TablesToStage, false)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
@@ -216,14 +216,7 @@ func stashChanges(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgPars
|
||||
return err
|
||||
}
|
||||
|
||||
if !apr.Contains(AllFlag) {
|
||||
allTblsToBeStashed, err = doltdb.FilterIgnoredTables(ctx, allTblsToBeStashed, roots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
roots, err = actions.StageTables(ctx, roots, allTblsToBeStashed)
|
||||
roots, err = actions.StageTables(ctx, roots, allTblsToBeStashed, !apr.Contains(AllFlag))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ func (mr *MultiRepoTestSetup) StageAll(dbName string) {
|
||||
mr.Errhand(fmt.Sprintf("Failed to get roots: %s", dbName))
|
||||
}
|
||||
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, true)
|
||||
if err != nil {
|
||||
mr.Errhand(fmt.Sprintf("Failed to stage tables: %s", dbName))
|
||||
}
|
||||
|
||||
+9
-6
@@ -21,22 +21,25 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
)
|
||||
|
||||
func StageTables(ctx context.Context, roots doltdb.Roots, tbls []string) (doltdb.Roots, error) {
|
||||
tbls, err := doltdb.FilterIgnoredTables(ctx, tbls, roots)
|
||||
if err != nil {
|
||||
return doltdb.Roots{}, err
|
||||
func StageTables(ctx context.Context, roots doltdb.Roots, tbls []string, filterIgnoredTables bool) (doltdb.Roots, error) {
|
||||
if filterIgnoredTables {
|
||||
var err error
|
||||
tbls, err = doltdb.FilterIgnoredTables(ctx, tbls, roots)
|
||||
if err != nil {
|
||||
return doltdb.Roots{}, err
|
||||
}
|
||||
}
|
||||
|
||||
return stageTables(ctx, roots, tbls)
|
||||
}
|
||||
|
||||
func StageAllTables(ctx context.Context, roots doltdb.Roots) (doltdb.Roots, error) {
|
||||
func StageAllTables(ctx context.Context, roots doltdb.Roots, filterIgnoredTables bool) (doltdb.Roots, error) {
|
||||
tbls, err := doltdb.UnionTableNames(ctx, roots.Staged, roots.Working)
|
||||
if err != nil {
|
||||
return doltdb.Roots{}, err
|
||||
}
|
||||
|
||||
return StageTables(ctx, roots, tbls)
|
||||
return StageTables(ctx, roots, tbls, filterIgnoredTables)
|
||||
}
|
||||
|
||||
func StageModifiedAndDeletedTables(ctx context.Context, roots doltdb.Roots) (doltdb.Roots, error) {
|
||||
|
||||
@@ -60,7 +60,7 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) {
|
||||
return 1, fmt.Errorf("db session not found")
|
||||
}
|
||||
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, !apr.Contains(cli.ForceFlag))
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
@@ -70,7 +70,7 @@ func doDoltAdd(ctx *sql.Context, args []string) (int, error) {
|
||||
return 1, err
|
||||
}
|
||||
} else {
|
||||
roots, err = actions.StageTables(ctx, roots, apr.Args)
|
||||
roots, err = actions.StageTables(ctx, roots, apr.Args, !apr.Contains(cli.ForceFlag))
|
||||
if err != nil {
|
||||
return 1, err
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ func doDoltCommit(ctx *sql.Context, args []string) (string, error) {
|
||||
}
|
||||
|
||||
if apr.Contains(cli.UpperCaseAllFlag) {
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, !apr.Contains(cli.AddIgnoredFlag))
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(err.Error())
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ func (d *DoltSession) PendingCommitAllStaged(ctx *sql.Context, dbName string, pr
|
||||
}
|
||||
|
||||
var err error
|
||||
roots, err = actions.StageAllTables(ctx, roots)
|
||||
roots, err = actions.StageAllTables(ctx, roots, true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user