mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-24 11:39:18 -05:00
Requested changes pt 2
This commit is contained in:
@@ -39,10 +39,6 @@ var StashCommands = cli.NewSubCommandHandlerWithUnspecified("stash", "Stash the
|
||||
StashPopCmd{},
|
||||
})
|
||||
|
||||
const (
|
||||
AllFlag = "all"
|
||||
)
|
||||
|
||||
var stashDocs = cli.CommandDocumentationContent{
|
||||
ShortDesc: "Stash the changes in a dirty working directory away.",
|
||||
LongDesc: `Use dolt stash when you want to record the current state of the working directory and the index, but want to go back to a clean working directory.
|
||||
@@ -78,7 +74,7 @@ func (cmd StashCmd) Docs() *cli.CommandDocumentation {
|
||||
func (cmd StashCmd) ArgParser() *argparser.ArgParser {
|
||||
ap := argparser.NewArgParserWithMaxArgs(cmd.Name(), 0)
|
||||
ap.SupportsFlag(cli.IncludeUntrackedFlag, "u", "Untracked tables are also stashed.")
|
||||
ap.SupportsFlag(AllFlag, "a", "All tables are stashed, including untracked and ignored tables.")
|
||||
ap.SupportsFlag(cli.AllFlag, "a", "All tables are stashed, including untracked and ignored tables.")
|
||||
return ap
|
||||
}
|
||||
|
||||
@@ -143,7 +139,7 @@ func hasLocalChanges(ctx context.Context, dEnv *env.DoltEnv, roots doltdb.Roots,
|
||||
}
|
||||
|
||||
// There are unstaged changes, is --all set? If so, nothing else matters. Stash them.
|
||||
if apr.Contains(AllFlag) {
|
||||
if apr.Contains(cli.AllFlag) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@@ -206,13 +202,13 @@ func stashChanges(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgPars
|
||||
// stage untracked files to include them in the stash,
|
||||
// but do not include them in added table set,
|
||||
// because they should not be staged when popped.
|
||||
if apr.Contains(cli.IncludeUntrackedFlag) || apr.Contains(AllFlag) {
|
||||
if apr.Contains(cli.IncludeUntrackedFlag) || apr.Contains(cli.AllFlag) {
|
||||
allTblsToBeStashed, err = doltdb.UnionTableNames(ctx, roots.Staged, roots.Working)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
roots, err = actions.StageTables(ctx, roots, allTblsToBeStashed, !apr.Contains(AllFlag))
|
||||
roots, err = actions.StageTables(ctx, roots, allTblsToBeStashed, !apr.Contains(cli.AllFlag))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -155,12 +155,7 @@ func doStashPush(ctx *sql.Context, dSess *dsess.DoltSession, dbData env.DbData[*
|
||||
return err
|
||||
}
|
||||
|
||||
err = updateWorkingSetFromRoots(ctx, dbData, roots)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return updateWorkingSetFromRoots(ctx, dbData, roots)
|
||||
}
|
||||
|
||||
func doStashPop(ctx *sql.Context, dbData env.DbData[*sql.Context], stashName string, idx int) error {
|
||||
@@ -191,29 +186,15 @@ func doStashPop(ctx *sql.Context, dbData env.DbData[*sql.Context], stashName str
|
||||
return err
|
||||
}
|
||||
|
||||
err = dbData.Ddb.RemoveStashAtIdx(ctx, idx, stashName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return dbData.Ddb.RemoveStashAtIdx(ctx, idx, stashName)
|
||||
}
|
||||
|
||||
func doStashDrop(ctx *sql.Context, dbData env.DbData[*sql.Context], stashName string, idx int) error {
|
||||
err := dbData.Ddb.RemoveStashAtIdx(ctx, idx, stashName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return dbData.Ddb.RemoveStashAtIdx(ctx, idx, stashName)
|
||||
}
|
||||
|
||||
func doStashClear(ctx *sql.Context, dbData env.DbData[*sql.Context], stashName string) error {
|
||||
err := dbData.Ddb.RemoveAllStashes(ctx, stashName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return dbData.Ddb.RemoveAllStashes(ctx, stashName)
|
||||
}
|
||||
|
||||
func stashedTableSets(ctx context.Context, roots doltdb.Roots) ([]doltdb.TableName, []doltdb.TableName, error) {
|
||||
@@ -359,12 +340,7 @@ func updateWorkingSetFromRoots(ctx *sql.Context, dbData env.DbData[*sql.Context]
|
||||
Description: "updated from dolt environment",
|
||||
}
|
||||
|
||||
err = dbData.Ddb.UpdateWorkingSet(ctx, ws.Ref(), ws, h, wsm, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return dbData.Ddb.UpdateWorkingSet(ctx, ws.Ref(), ws, h, wsm, nil)
|
||||
}
|
||||
|
||||
func parseStashIndex(apr *argparser.ArgParseResults) (int, error) {
|
||||
@@ -423,12 +399,7 @@ func updateWorkingRoot(ctx *sql.Context, dbData env.DbData[*sql.Context], newRoo
|
||||
Description: "updated from dolt environment",
|
||||
}
|
||||
|
||||
err = dbData.Ddb.UpdateWorkingSet(ctx, wsRef, ws.WithWorkingRoot(newRoot), h, wsm, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return dbData.Ddb.UpdateWorkingSet(ctx, wsRef, ws.WithWorkingRoot(newRoot), h, wsm, nil)
|
||||
}
|
||||
|
||||
// gatherCommitData is a helper function that returns the commit and commit metadata associated with the current head
|
||||
|
||||
@@ -16,11 +16,10 @@ package dtables
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
|
||||
"github.com/dolthub/go-mysql-server/sql"
|
||||
"github.com/dolthub/go-mysql-server/sql/types"
|
||||
"io"
|
||||
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
|
||||
@@ -151,17 +150,8 @@ func (itr *StashItr) Next(*sql.Context) (sql.Row, error) {
|
||||
|
||||
// BranchName and StashReference are of the form refs/heads/name
|
||||
// or refs/stashes/name, so we need to parse them to get names
|
||||
parsedRef := strings.Split(stash.BranchName, "/")
|
||||
if len(parsedRef) != 3 {
|
||||
return nil, fmt.Errorf("Invalid branch name: %s", stash.BranchName)
|
||||
}
|
||||
branch := parsedRef[2]
|
||||
|
||||
parsedRef = strings.Split(stash.StashReference, "/")
|
||||
if len(parsedRef) != 3 {
|
||||
return nil, fmt.Errorf("Bad reference: %s", stash.StashReference)
|
||||
}
|
||||
stashRef := parsedRef[2]
|
||||
branch := ref.NewBranchRef(stash.BranchName).GetPath()
|
||||
stashRef := ref.NewStashRef(stash.StashReference).GetPath()
|
||||
|
||||
return sql.NewRow(stashRef, stash.Name, branch, commitHash.String(), stash.Description), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user