mirror of
https://github.com/dolthub/dolt.git
synced 2026-05-22 02:51:21 -05:00
Migrate uses of CWBHeadRef and CWBHeadSpec in commands module.
This commit is contained in:
@@ -183,7 +183,11 @@ func getCherryPickedRootValue(ctx context.Context, dEnv *env.DoltEnv, workingRoo
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
cherryCm, err := dEnv.DoltDB.Resolve(ctx, cherrySpec, dEnv.RepoStateReader().CWBHeadRef())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
cherryCm, err := dEnv.DoltDB.Resolve(ctx, cherrySpec, headRef)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
|
||||
@@ -186,7 +186,12 @@ func getNerf(ctx context.Context, dEnv *env.DoltEnv, apr *argparser.ArgParseResu
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(ctx, cs, dEnv.RepoStateReader().CWBHeadRef())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(ctx, cs, headRef)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -249,7 +249,10 @@ func (opts *logOpts) parseRefsAndTable(ctx context.Context, apr *argparser.ArgPa
|
||||
|
||||
opts.excludingCommitSpecs = append(opts.excludingCommitSpecs, notCs)
|
||||
} else {
|
||||
argIsRef := actions.IsValidRef(ctx, arg, dEnv.DoltDB, dEnv.RepoStateReader())
|
||||
argIsRef, err := actions.IsValidRef(ctx, arg, dEnv.DoltDB, dEnv.RepoStateReader())
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
// <ref>
|
||||
if argIsRef && !seenRefs[arg] {
|
||||
cs, err := getCommitSpec(arg)
|
||||
|
||||
@@ -121,7 +121,12 @@ func getRootForCommitSpecStr(ctx context.Context, csStr string, dEnv *env.DoltEn
|
||||
return "", nil, bdr.AddCause(err).Build()
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(ctx, cs, dEnv.RepoStateReader().CWBHeadRef())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return "", nil, errhand.VerboseErrorFromError(err)
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(ctx, cs, headRef)
|
||||
|
||||
if err != nil {
|
||||
return "", nil, errhand.BuildDError(`Unable to resolve "%s"`, csStr).AddCause(err).Build()
|
||||
|
||||
@@ -159,7 +159,12 @@ func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string,
|
||||
return handleCommitErr(ctx, dEnv, err, usage)
|
||||
}
|
||||
|
||||
suggestedMsg := fmt.Sprintf("Merge branch '%s' into %s", commitSpecStr, dEnv.RepoStateReader().CWBHeadRef().GetPath())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return handleCommitErr(ctx, dEnv, err, usage)
|
||||
}
|
||||
|
||||
suggestedMsg := fmt.Sprintf("Merge branch '%s' into %s", commitSpecStr, headRef.GetPath())
|
||||
msg := ""
|
||||
if m, ok := apr.GetValue(cli.MessageArg); ok {
|
||||
msg = m
|
||||
@@ -529,10 +534,15 @@ func executeNoFFMergeAndCommit(ctx context.Context, dEnv *env.DoltEnv, spec *mer
|
||||
Email: spec.Email,
|
||||
})
|
||||
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return tblToStats, err
|
||||
}
|
||||
|
||||
wsHash, err := ws.HashOf()
|
||||
_, err = dEnv.DoltDB.CommitWithWorkingSet(
|
||||
ctx,
|
||||
dEnv.RepoStateReader().CWBHeadRef(),
|
||||
headRef,
|
||||
ws.Ref(),
|
||||
pendingCommit,
|
||||
ws.WithStagedRoot(pendingCommit.Roots.Staged).WithWorkingRoot(pendingCommit.Roots.Working).ClearMerge(),
|
||||
|
||||
@@ -119,7 +119,12 @@ func ResolveCommitWithVErr(dEnv *env.DoltEnv, cSpecStr string) (*doltdb.Commit,
|
||||
return nil, errhand.BuildDError("'%s' is not a valid commit", cSpecStr).Build()
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(context.TODO(), cs, dEnv.RepoStateReader().CWBHeadRef())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return nil, errhand.VerboseErrorFromError(err)
|
||||
}
|
||||
|
||||
cm, err := dEnv.DoltDB.Resolve(context.TODO(), cs, headRef)
|
||||
if err != nil {
|
||||
if errors.Is(err, doltdb.ErrInvalidAncestorSpec) {
|
||||
return nil, errhand.BuildDError("'%s' could not resolve ancestor spec", cSpecStr).Build()
|
||||
|
||||
@@ -202,7 +202,12 @@ func pullHelper(ctx context.Context, dEnv *env.DoltEnv, pullSpec *env.PullSpec)
|
||||
return err
|
||||
}
|
||||
|
||||
suggestedMsg := fmt.Sprintf("Merge branch '%s' of %s into %s", pullSpec.Branch.GetPath(), pullSpec.Remote.Url, dEnv.RepoStateReader().CWBHeadRef().GetPath())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
suggestedMsg := fmt.Sprintf("Merge branch '%s' of %s into %s", pullSpec.Branch.GetPath(), pullSpec.Remote.Url, headRef.GetPath())
|
||||
tblStats, err := performMerge(ctx, dEnv, mergeSpec, suggestedMsg)
|
||||
printSuccessStats(tblStats)
|
||||
if err != nil {
|
||||
|
||||
@@ -103,7 +103,11 @@ func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string,
|
||||
} else {
|
||||
if apr.NArg() == 1 {
|
||||
ref := apr.Arg(0)
|
||||
if actions.IsValidRef(ctx, ref, dEnv.DoltDB, dEnv.RepoStateReader()) {
|
||||
isValidRef, err := actions.IsValidRef(ctx, ref, dEnv.DoltDB, dEnv.RepoStateReader())
|
||||
if err != nil {
|
||||
return handleErrAndExit(err)
|
||||
}
|
||||
if isValidRef {
|
||||
return handleResetSoftToRef(ctx, dEnv, ref, usage)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,11 @@ func applyStashAtIdx(ctx context.Context, dEnv *env.DoltEnv, curWorkingRoot *dol
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
parentCommit, err := dEnv.DoltDB.Resolve(ctx, headCommitSpec, dEnv.RepoStateReader().CWBHeadRef())
|
||||
headRef, err := dEnv.RepoStateReader().CWBHeadRef()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
parentCommit, err := dEnv.DoltDB.Resolve(ctx, headCommitSpec, headRef)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user