feat(create_project): add dispatch_allow to inject .dispatch-allow (#43)
Optional dispatch_allow bool (default false). When true, inject a .dispatch-allow file at repo root on the resolved default branch after substitution, marking the new project dispatch-eligible (dispatch#3) without a manual follow-up commit. Rides the existing upsertRetry path so injection inherits the infra#179 branch-readiness / partial_failure handling; a stalled injection degrades exactly like substitution. Reported in files_substituted. false/omitted is byte-for-byte unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -226,6 +226,38 @@ func TestCreateProject_WriteFailure_PartialFailure(t *testing.T) {
|
||||
assert.Contains(t, out.PartialFailure, "go.mod")
|
||||
}
|
||||
|
||||
// dispatch_allow injects a .dispatch-allow file (dispatch#3) only when true.
|
||||
func TestCreateProject_DispatchAllow(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
argsJSON string
|
||||
wantFile bool
|
||||
}{
|
||||
{"true injects .dispatch-allow", `{"owner":"mathias","name":"new-svc","dispatch_allow":true}`, true},
|
||||
{"false does not inject", `{"owner":"mathias","name":"new-svc","dispatch_allow":false}`, false},
|
||||
{"omitted does not inject", `{"owner":"mathias","name":"new-svc"}`, false},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
files := map[string]string{"go.mod": "module __MODULE_PATH__\n"}
|
||||
f := newFakeTemplateServer(files, "main")
|
||||
srv := httptest.NewServer(f.handler(t, "template-go-agent", "new-svc"))
|
||||
defer srv.Close()
|
||||
|
||||
out := callTool(t, srv.URL, "template-go-agent", tc.argsJSON)
|
||||
require.Empty(t, out.PartialFailure)
|
||||
if tc.wantFile {
|
||||
assert.Contains(t, out.FilesSubstituted, ".dispatch-allow")
|
||||
assert.Contains(t, f.puts, ".dispatch-allow")
|
||||
assert.Contains(t, f.putBodies[".dispatch-allow"], "dispatch#3")
|
||||
} else {
|
||||
assert.NotContains(t, out.FilesSubstituted, ".dispatch-allow")
|
||||
assert.NotContains(t, f.puts, ".dispatch-allow")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// ── guardrails unchanged by the rewrite ──────────────────────────────────────
|
||||
|
||||
func TestCreateProject_NameRegexFailure(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user