mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 18:49:14 -06:00
checkout proc startpoint (#3557)
* checkout proc startpoint * zach comments
This commit is contained in:
committed by
GitHub
parent
0623d8a308
commit
1f39d77f6e
@@ -78,6 +78,8 @@ func DoDoltCheckout(ctx *sql.Context, args []string) (int, error) {
|
||||
if newBranch, newBranchOk := apr.GetValue(cli.CheckoutCoBranch); newBranchOk {
|
||||
if len(newBranch) == 0 {
|
||||
err = errors.New("error: cannot checkout empty string")
|
||||
} else if len(apr.Args) > 0 {
|
||||
err = checkoutNewBranch(ctx, dbName, dbData, roots, newBranch, apr.Arg(0))
|
||||
} else {
|
||||
err = checkoutNewBranch(ctx, dbName, dbData, roots, newBranch, "")
|
||||
}
|
||||
|
||||
@@ -1433,6 +1433,39 @@ var DoltBranchScripts = []queries.ScriptTest{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "Create branch from startpoint",
|
||||
SetUpScript: []string{
|
||||
"create table a (x int)",
|
||||
"set @commit1 = (select DOLT_COMMIT('-am', 'add table a'));",
|
||||
},
|
||||
Assertions: []queries.ScriptTestAssertion{
|
||||
{
|
||||
Query: "show tables",
|
||||
Expected: []sql.Row{{"a"}, {"myview"}},
|
||||
},
|
||||
{
|
||||
Query: "CALL DOLT_CHECKOUT('-b', 'newBranch', 'head~1')",
|
||||
Expected: []sql.Row{{0}},
|
||||
},
|
||||
{
|
||||
Query: "show tables",
|
||||
Expected: []sql.Row{{"myview"}},
|
||||
},
|
||||
{
|
||||
Query: "CALL DOLT_CHECKOUT('-b', 'newBranch2', @commit1)",
|
||||
Expected: []sql.Row{{0}},
|
||||
},
|
||||
{
|
||||
Query: "show tables",
|
||||
Expected: []sql.Row{{"a"}, {"myview"}},
|
||||
},
|
||||
{
|
||||
Query: "CALL DOLT_CHECKOUT('-b', 'otherBranch', 'unknownCommit')",
|
||||
ExpectedErrStr: "fatal: 'unknownCommit' is not a commit and a branch 'otherBranch' cannot be created from it",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var DoltReset = []queries.ScriptTest{
|
||||
|
||||
Reference in New Issue
Block a user