| 1 | package thin |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "fmt" |
| 7 | |
| 8 | "amadan.net/oficina/equipo/internal/runner/workspace" |
| 9 | ) |
| 10 | |
| 11 | const ( |
| 12 | copyMergeSandboxMask = "Merge refused: %s is a new empty file at a sandbox placeholder path. Remove it or add the intended contents before merging." // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| 13 | copyMergeSandboxCheck = "Could not check the branch for sandbox placeholder files: %v" // COPY ACCEPTED BY DELEGATION (Astra, 2026-11-13) |
| 14 | ) |
| 15 | |
| 16 | // Every actual merge request checks the judged commit against the current |
| 17 | // default branch. Reconciliation of an already landed merge needs no check. |
| 18 | func (e *Engineer) mergeSandboxDetail(ctx context.Context, r stepRow) string { |
| 19 | ctx, cancel := context.WithTimeout(ctx, fetchTimeout) |
| 20 | defer cancel() |
| 21 | _, base, _, err := e.Clones.Heads(ctx, r.Repo, nil) |
| 22 | if err != nil && !errors.Is(err, ErrEmptyRepo) { |
| 23 | return fmt.Sprintf(copyMergeSandboxCheck, err) |
| 24 | } |
| 25 | if err := e.fetch(ctx, r.Repo); err != nil { |
| 26 | return fmt.Sprintf(copyMergeSandboxCheck, err) |
| 27 | } |
| 28 | tree := workspace.TaskTree{Git: e.O.Runner.GitPath, GitDir: e.Clones.Path(r.Repo), Dir: e.Clones.Path(r.Repo)} |
| 29 | paths, err := tree.AddedSandboxMasks(ctx, base, r.CandidateSHA) |
| 30 | if err != nil { |
| 31 | return fmt.Sprintf(copyMergeSandboxCheck, err) |
| 32 | } |
| 33 | if len(paths) > 0 { |
| 34 | return fmt.Sprintf(copyMergeSandboxMask, fmt.Sprintf("%q", paths[0])) |
| 35 | } |
| 36 | return "" |
| 37 | } |
| 38 | |