mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-14 10:09:09 -06:00
simpler error message in SQL context, fuller one on CLI
This commit is contained in:
@@ -72,6 +72,8 @@ const (
|
||||
showCurrentFlag = "show-current"
|
||||
)
|
||||
|
||||
var ErrUnmergedBranchDelete = errors.New("The branch '%s' is not fully merged.\nIf you are sure you want to delete it, run 'dolt branch -D %s'.")
|
||||
|
||||
type BranchCmd struct{}
|
||||
|
||||
// Name is returns the name of the Dolt cli command. This is what is used on the command line to invoke the command
|
||||
@@ -328,6 +330,8 @@ func deleteBranches(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgPa
|
||||
var verr errhand.VerboseError
|
||||
if err == doltdb.ErrBranchNotFound {
|
||||
verr = errhand.BuildDError("fatal: branch '%s' not found", brName).Build()
|
||||
} else if err == actions.ErrUnmergedBranch {
|
||||
verr = errhand.BuildDError(ErrUnmergedBranchDelete.Error(), brName, brName).Build()
|
||||
} else if err == actions.ErrCOBranchDelete {
|
||||
verr = errhand.BuildDError("error: Cannot delete checked out branch '%s'", brName).Build()
|
||||
} else {
|
||||
|
||||
10
go/libraries/doltcore/env/actions/branch.go
vendored
10
go/libraries/doltcore/env/actions/branch.go
vendored
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
var ErrAlreadyExists = errors.New("already exists")
|
||||
var ErrCOBranchDelete = errors.New("attempted to delete checked out branch")
|
||||
var ErrUnmergedBranchDelete = errors.New("The branch '%s' is not fully merged.\nIf you are sure you want to delete it, run 'dolt branch -D %s'.")
|
||||
var ErrUnmergedBranch = errors.New("branch is not fully merged")
|
||||
var ErrWorkingSetsOnBothBranches = errors.New("checkout would overwrite uncommitted changes on target branch")
|
||||
|
||||
func RenameBranch(ctx context.Context, dbData env.DbData, oldBranch, newBranch string, remoteDbPro env.RemoteDbProvider, force bool) error {
|
||||
@@ -205,7 +205,7 @@ func validateBranchMergedIntoCurrentWorkingBranch(ctx context.Context, dbdata en
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, doltdb.ErrIsAhead) {
|
||||
return fmt.Errorf(ErrUnmergedBranchDelete.Error(), branch.GetPath(), branch.GetPath())
|
||||
return ErrUnmergedBranch
|
||||
}
|
||||
|
||||
// TODO: no common ancestor is not an error
|
||||
@@ -213,7 +213,7 @@ func validateBranchMergedIntoCurrentWorkingBranch(ctx context.Context, dbdata en
|
||||
}
|
||||
|
||||
if !isMerged {
|
||||
return fmt.Errorf(ErrUnmergedBranchDelete.Error(), branch.GetPath(), branch.GetPath())
|
||||
return ErrUnmergedBranch
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -257,14 +257,14 @@ func validateBranchMergedIntoUpstream(ctx context.Context, dbdata env.DbData, br
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, doltdb.ErrIsAhead) {
|
||||
return fmt.Errorf(ErrUnmergedBranchDelete.Error(), branch.GetPath(), branch.GetPath())
|
||||
return ErrUnmergedBranch
|
||||
}
|
||||
// TODO: no common ancestor is not an error
|
||||
return err
|
||||
}
|
||||
|
||||
if !canFF {
|
||||
return fmt.Errorf(ErrUnmergedBranchDelete.Error(), branch.GetPath(), branch.GetPath())
|
||||
return ErrUnmergedBranch
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1713,7 +1713,7 @@ var DoltBranchScripts = []queries.ScriptTest{
|
||||
{
|
||||
// Trying to delete a branch with unpushed changes fails without force option
|
||||
Query: "CALL DOLT_BRANCH('-d', 'myNewBranchWithCommit')",
|
||||
ExpectedErrStr: "attempted to delete a branch that is not fully merged into its parent; use `-f` to force",
|
||||
ExpectedErrStr: "branch is not fully merged",
|
||||
},
|
||||
{
|
||||
Query: "CALL DOLT_BRANCH('-df', 'myNewBranchWithCommit')",
|
||||
|
||||
Reference in New Issue
Block a user