checkpoint: multi-repo Gitea ingestion, per-project repos, rotation anchor_sha fix
Pre-existing uncommitted work found at session start: rotation now emits anchor_sha on TaskReleased (previously silently dropped by store.Append validation), multi-repo Gitea provider support, per-project git worktree roots, and associated test coverage. Committing as a checkpoint before starting remediation work tracked in AUDIT.md.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package orchestrator_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"orchestra/internal/domain"
|
||||
"orchestra/internal/orchestrator"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func initRepo(t *testing.T, dir string) {
|
||||
t.Helper()
|
||||
run := func(args ...string) {
|
||||
cmd := exec.Command("git", args...)
|
||||
cmd.Dir = dir
|
||||
cmd.Env = append(os.Environ(), "GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@t", "GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@t")
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
t.Fatalf("git %v: %v: %s", args, err, out)
|
||||
}
|
||||
}
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
run("init")
|
||||
if err := os.WriteFile(filepath.Join(dir, "README"), []byte("x"), 0644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
run("add", "README")
|
||||
run("commit", "-m", "init")
|
||||
}
|
||||
|
||||
func TestPerProjectGitWorktreesResolvesByProject(t *testing.T) {
|
||||
base := t.TempDir()
|
||||
repoA := filepath.Join(base, "repo-a")
|
||||
repoB := filepath.Join(base, "repo-b")
|
||||
initRepo(t, repoA)
|
||||
initRepo(t, repoB)
|
||||
|
||||
w := orchestrator.PerProjectGitWorktrees{
|
||||
Projects: map[string]orchestrator.ProjectRepo{
|
||||
"proj-a": {Repo: repoA, WorktreeRoot: filepath.Join(base, "wt-a")},
|
||||
},
|
||||
Default: orchestrator.GitWorktrees{Root: filepath.Join(base, "wt-default"), Repo: repoB},
|
||||
}
|
||||
|
||||
pathA, err := w.Create(context.Background(), domain.Task{ID: "t1", Project: "proj-a"})
|
||||
if err != nil {
|
||||
t.Fatalf("create for proj-a: %v", err)
|
||||
}
|
||||
if filepath.Dir(pathA) != filepath.Join(base, "wt-a") {
|
||||
t.Fatalf("expected proj-a worktree under wt-a, got %s", pathA)
|
||||
}
|
||||
|
||||
pathDefault, err := w.Create(context.Background(), domain.Task{ID: "t2", Project: "unconfigured-project"})
|
||||
if err != nil {
|
||||
t.Fatalf("create for unconfigured project: %v", err)
|
||||
}
|
||||
if filepath.Dir(pathDefault) != filepath.Join(base, "wt-default") {
|
||||
t.Fatalf("expected unconfigured project to use default worktree root, got %s", pathDefault)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user