(ctx context.Context, env *environment.Environment, explanation string)
| 209 | } |
| 210 | |
| 211 | func (r *Repository) propagateToWorktree(ctx context.Context, env *environment.Environment, explanation string) (rerr error) { |
| 212 | slog.Info("Propagating to worktree...", |
| 213 | "environment.id", env.ID, |
| 214 | "workdir", env.State.Config.Workdir, |
| 215 | "id", env.ID) |
| 216 | defer func() { |
| 217 | slog.Info("Propagating to worktree... (DONE)", |
| 218 | "environment.id", env.ID, |
| 219 | "workdir", env.State.Config.Workdir, |
| 220 | "id", env.ID, |
| 221 | "err", rerr) |
| 222 | }() |
| 223 | |
| 224 | if err := r.exportEnvironment(ctx, env); err != nil { |
| 225 | return err |
| 226 | } |
| 227 | |
| 228 | worktreePath, err := r.WorktreePath(env.ID) |
| 229 | if err != nil { |
| 230 | return fmt.Errorf("failed to get worktree path: %w", err) |
| 231 | } |
| 232 | |
| 233 | if err := r.commitWorktreeChanges(ctx, worktreePath, explanation); err != nil { |
| 234 | return fmt.Errorf("failed to commit worktree changes: %w", err) |
| 235 | } |
| 236 | |
| 237 | if err := r.saveState(ctx, env); err != nil { |
| 238 | return fmt.Errorf("failed to add notes: %w", err) |
| 239 | } |
| 240 | |
| 241 | if err := r.lockManager.WithLock(ctx, LockTypeUserRepo, func() error { |
| 242 | slog.Info("Fetching container-use remote in source repository") |
| 243 | _, err := RunGitCommand(ctx, r.userRepoPath, "fetch", containerUseRemote, env.ID) |
| 244 | return err |
| 245 | }); err != nil { |
| 246 | return err |
| 247 | } |
| 248 | |
| 249 | if err := r.propagateGitNotes(ctx, gitNotesStateRef); err != nil { |
| 250 | return err |
| 251 | } |
| 252 | |
| 253 | return nil |
| 254 | } |
| 255 | |
| 256 | func (r *Repository) exportEnvironment(ctx context.Context, env *environment.Environment) error { |
| 257 | worktreePointer := fmt.Sprintf("gitdir: %s", filepath.Join(r.forkRepoPath, "worktrees", env.ID)) |
no test coverage detected