Add getTemporaryStore helper to dedup store access · Entire
Add getTemporaryStore helper to dedup store access
5503271→main· pfleidi·4w ago·3 files·+13 added/-6 removed
SaveStep, SaveTaskStep, and GetRewindPoints each repeated the getCheckpointStores + Temporary() pair. A getTemporaryStore accessor mirrors getCheckpointStore so each call site is a single line, with getCheckpointStores remaining the shared open-with-blob-fetcher wrapper.
Sessions
684fdbdfe046View transcript
?\ Simplify Store Access with HelperClaude Code·Opus 4.8[1m]·1 step
Changes
3
cmd/entire/cli/strategy
Mmanual_commit.go+10
Mmanual_commit_git.go+2/-4
Mmanual_commit_rewind.go+1/-2
59 unmodified lines
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
59 unmodified lines
return stores.Primary, nil
}
// getTemporaryStore returns the git-backed shadow-branch store with the
// strategy's blob fetcher wired in.
func (s *ManualCommitStrategy) getTemporaryStore(ctx context.Context, repo *git.Repository) (checkpoint.TemporaryStore, error) { //nolint:ireturn // temporary store capability is the abstraction boundary
stores, err := s.getCheckpointStores(ctx, repo)
if err != nil {
return nil, err
}
return stores.Temporary(), nil
}
// NewManualCommitStrategy creates a new manual-commit strategy instance.
func NewManualCommitStrategy() *ManualCommitStrategy {
return &ManualCommitStrategy{}
}
Mcmd/entire/cli/strategy/manual_commit.go+10
51 unmodified lines
52
53
54
55
55
56
57
58
59
59
60
61
123 unmodified lines
185
186
187
189
188
189
190
191
193
192
193
194
51 unmodified lines
}
migrateSpan.End()
stores, err := s.getCheckpointStores(ctx, repo)
store, err := s.getTemporaryStore(ctx, repo)
if err != nil {
return err
}
store := stores.Temporary()
shadowBranchName := checkpoint.ShadowBranchNameForCommit(state.BaseCommit, state.WorktreeID)
branchExisted := store.ShadowBranchExists(state.BaseCommit, state.WorktreeID)
123 unmodified lines
return fmt.Errorf("failed to check/migrate shadow branch: %w", err)
}
stores, err := s.getCheckpointStores(ctx, repo)
store, err := s.getTemporaryStore(ctx, repo)
if err != nil {
return err
}
store := stores.Temporary()
shadowBranchName := checkpoint.ShadowBranchNameForCommit(state.BaseCommit, state.WorktreeID)
branchExisted := store.ShadowBranchExists(state.BaseCommit, state.WorktreeID)
Mcmd/entire/cli/strategy/manual_commit_git.go+2/-4
37 unmodified lines
38
39
40
41
41
42
43
44
45
45
46
47
37 unmodified lines
}
defer repo.Close()
stores, err := s.getCheckpointStores(ctx, repo)
store, err := s.getTemporaryStore(ctx, repo)
if err != nil {
return nil, err
}
store := stores.Temporary()
// Get current HEAD to find matching shadow branch
head, err := repo.Head()
Mcmd/entire/cli/strategy/manual_commit_rewind.go+1/-2