(ctx context.Context, env *environment.Environment)
| 296 | } |
| 297 | |
| 298 | func (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 | |
| 323 | func (r *Repository) loadState(ctx context.Context, worktreePath string) ([]byte, error) { |
| 324 | var result []byte |
no test coverage detected