mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-23 13:48:42 -05:00
Fixed bug in initializing repo state
This commit is contained in:
+8
-8
@@ -322,22 +322,22 @@ func (dEnv *DoltEnv) InitializeRepoState(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
rootHash, err := root.HashOf()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: stop reading repo state
|
||||
dEnv.RepoState, err = CreateRepoState(dEnv.FS, doltdb.MasterBranch, rootHash)
|
||||
dEnv.RepoState, err = CreateRepoState(dEnv.FS, doltdb.MasterBranch)
|
||||
if err != nil {
|
||||
return ErrStateUpdate
|
||||
}
|
||||
|
||||
// TODO: combine into one update
|
||||
err = dEnv.UpdateWorkingRoot(ctx, root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dEnv.UpdateStagedRoot(ctx, root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dEnv.RSLoadErr = nil
|
||||
return nil
|
||||
}
|
||||
@@ -597,7 +597,7 @@ func (dEnv *DoltEnv) UpdateStagedRoot(ctx context.Context, newRoot *doltdb.RootV
|
||||
wsRef = ws.Ref()
|
||||
}
|
||||
|
||||
return dEnv.DoltDB.UpdateWorkingSet(ctx, wsRef, ws.WithWorkingRoot(newRoot), h)
|
||||
return dEnv.DoltDB.UpdateWorkingSet(ctx, wsRef, ws.WithStagedRoot(newRoot), h)
|
||||
}
|
||||
|
||||
// todo: move this out of env to actions
|
||||
|
||||
+1
-3
@@ -28,7 +28,6 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdocs"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/ref"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/filesys"
|
||||
"github.com/dolthub/dolt/go/store/hash"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
)
|
||||
|
||||
@@ -51,9 +50,8 @@ func createTestEnv(isInitialized bool, hasLocalConfig bool) *DoltEnv {
|
||||
initialDirs = append(initialDirs, doltDir)
|
||||
initialDirs = append(initialDirs, doltDataDir)
|
||||
|
||||
hashStr := hash.Hash{}.String()
|
||||
masterRef := ref.NewBranchRef("master")
|
||||
repoState := &RepoState{ref.MarshalableRef{Ref: masterRef}, hashStr, hashStr, nil, nil, nil}
|
||||
repoState := &RepoState{Head: ref.MarshalableRef{Ref: masterRef}}
|
||||
repoStateData, err := json.Marshal(repoState)
|
||||
|
||||
if err != nil {
|
||||
|
||||
+4
-2
@@ -38,7 +38,7 @@ type RepoStateReader interface {
|
||||
GetPreMergeWorking() string
|
||||
}
|
||||
|
||||
type RepoStateWriter interface {error
|
||||
type RepoStateWriter interface {
|
||||
UpdateStagedRoot(ctx context.Context, newRoot *doltdb.RootValue) error
|
||||
UpdateWorkingRoot(ctx context.Context, newRoot *doltdb.RootValue) error
|
||||
SetCWBHeadRef(context.Context, ref.MarshalableRef) error
|
||||
@@ -121,7 +121,7 @@ func CloneRepoState(fs filesys.ReadWriteFS, r Remote) (*RepoState, error) {
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
func CreateRepoState(fs filesys.ReadWriteFS, br string, rootHash hash.Hash) (*RepoState, error) {
|
||||
func CreateRepoState(fs filesys.ReadWriteFS, br string) (*RepoState, error) {
|
||||
headRef, err := ref.Parse(br)
|
||||
|
||||
if err != nil {
|
||||
@@ -215,11 +215,13 @@ func HeadRoot(ctx context.Context, ddb *doltdb.DoltDB, rsr RepoStateReader) (*do
|
||||
}
|
||||
|
||||
// Returns the staged root.
|
||||
// TODO: remove this
|
||||
func StagedRoot(ctx context.Context, ddb *doltdb.DoltDB, rsr RepoStateReader) (*doltdb.RootValue, error) {
|
||||
return rsr.StagedRoot(ctx)
|
||||
}
|
||||
|
||||
// Updates the staged root.
|
||||
// TODO: remove this
|
||||
func UpdateStagedRoot(ctx context.Context, ddb *doltdb.DoltDB, rsw RepoStateWriter, newRoot *doltdb.RootValue) error {
|
||||
err := rsw.UpdateStagedRoot(ctx, newRoot)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,10 @@ type SessionRepoStateReader struct {
|
||||
dbName string
|
||||
}
|
||||
|
||||
func (s SessionRepoStateReader) StagedRoot(ctx context.Context) (*doltdb.RootValue, error) {
|
||||
panic("staged root not in session yet")
|
||||
}
|
||||
|
||||
func (s SessionRepoStateReader) WorkingRoot(ctx context.Context) (*doltdb.RootValue, error) {
|
||||
return s.session.roots[s.dbName].root, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user