MCPcopy Index your code
hub / github.com/dagger/container-use / saveState

Method saveState

repository/git.go:298–321  ·  view source on GitHub ↗
(ctx context.Context, env *environment.Environment)

Source from the content-addressed store, hash-verified

296}
297
298func (r *Repository) saveState(ctx context.Context, env *environment.Environment) error {
299 state, err := env.State.Marshal()
300 if err != nil {
301 return err
302 }
303 worktreePath, err := r.WorktreePath(env.ID)
304 if err != nil {
305 return fmt.Errorf("failed to get worktree path: %w", err)
306 }
307
308 f, err := os.CreateTemp(os.TempDir(), ".container-use-git-notes-*")
309 if err != nil {
310 return err
311 }
312 defer f.Close()
313 if _, err := f.Write(state); err != nil {
314 return err
315 }
316
317 return r.lockManager.WithLock(ctx, LockTypeNotes, func() error {
318 _, err = RunGitCommand(ctx, worktreePath, "notes", "--ref", gitNotesStateRef, "add", "-f", "-F", f.Name())
319 return err
320 })
321}
322
323func (r *Repository) loadState(ctx context.Context, worktreePath string) ([]byte, error) {
324 var result []byte

Callers 1

propagateToWorktreeMethod · 0.95

Calls 5

WorktreePathMethod · 0.95
RunGitCommandFunction · 0.85
MarshalMethod · 0.80
CloseMethod · 0.80
WithLockMethod · 0.45

Tested by

no test coverage detected