diff options
| author | Claude Agent <agent@claudomator.local> | 2026-04-03 23:31:15 +0000 |
|---|---|---|
| committer | Claude Agent <agent@claudomator.local> | 2026-04-03 23:31:15 +0000 |
| commit | 97eef0c964fb5d0dd53c66cec389831de8316fe0 (patch) | |
| tree | 19685359f40cf7322ffafc5ab6beea392d4df42c /internal/task | |
| parent | 1271ba1d329c8b16062600dfafdec1d06c735c2e (diff) | |
refactor: replace Task.Project+RepositoryURL+BranchName with ProjectID FKstory/task-project-fk
- Task.Project (human-readable name) replaced by Task.ProjectID (FK to Project.ID)
- Task.RepositoryURL changed to derived-only (yaml:"-"), computed at runtime from ProjectID
- Validator now accepts project_id OR repository_url (either satisfies the requirement)
- Update task_test.go and validator_test.go accordingly
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/task')
| -rw-r--r-- | internal/task/task.go | 4 | ||||
| -rw-r--r-- | internal/task/task_test.go | 14 | ||||
| -rw-r--r-- | internal/task/validator.go | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/internal/task/task.go b/internal/task/task.go index 0d1026f..73e69d3 100644 --- a/internal/task/task.go +++ b/internal/task/task.go @@ -73,8 +73,8 @@ type Task struct { ParentTaskID string `yaml:"parent_task_id" json:"parent_task_id"` Name string `yaml:"name" json:"name"` Description string `yaml:"description" json:"description"` - Project string `yaml:"project" json:"project"` // Human-readable project name - RepositoryURL string `yaml:"repository_url" json:"repository_url"` + ProjectID string `yaml:"project_id" json:"project_id"` // FK to Project.ID + RepositoryURL string `yaml:"-" json:"repository_url,omitempty"` // derived at runtime from ProjectID Agent AgentConfig `yaml:"agent" json:"agent"` Timeout Duration `yaml:"timeout" json:"timeout"` Retry RetryConfig `yaml:"retry" json:"retry"` diff --git a/internal/task/task_test.go b/internal/task/task_test.go index e6a17b8..72ff049 100644 --- a/internal/task/task_test.go +++ b/internal/task/task_test.go @@ -101,18 +101,18 @@ func TestDuration_MarshalYAML(t *testing.T) { } } -func TestTask_ProjectField(t *testing.T) { +func TestTask_ProjectIDField(t *testing.T) { t.Run("struct assignment", func(t *testing.T) { - task := Task{Project: "my-project"} - if task.Project != "my-project" { - t.Errorf("expected Project 'my-project', got %q", task.Project) + task := Task{ProjectID: "proj-123"} + if task.ProjectID != "proj-123" { + t.Errorf("expected ProjectID 'proj-123', got %q", task.ProjectID) } }) t.Run("yaml parsing", func(t *testing.T) { yaml := ` name: "Test Task" -project: my-project +project_id: proj-123 agent: instructions: "Do something" ` @@ -123,8 +123,8 @@ agent: if len(tasks) != 1 { t.Fatalf("expected 1 task, got %d", len(tasks)) } - if tasks[0].Project != "my-project" { - t.Errorf("expected Project 'my-project', got %q", tasks[0].Project) + if tasks[0].ProjectID != "proj-123" { + t.Errorf("expected ProjectID 'proj-123', got %q", tasks[0].ProjectID) } }) } diff --git a/internal/task/validator.go b/internal/task/validator.go index 43e482e..893bd18 100644 --- a/internal/task/validator.go +++ b/internal/task/validator.go @@ -29,8 +29,8 @@ func Validate(t *Task) error { if t.Name == "" { ve.Add("name is required") } - if t.RepositoryURL == "" { - ve.Add("repository_url is required") + if t.ProjectID == "" && t.RepositoryURL == "" { + ve.Add("project_id or repository_url is required") } if t.Agent.Instructions == "" { ve.Add("agent.instructions is required") |
