fix(create_project): handle gitea generate-async branch race (#42)
Live e2e surfaced a race unit tests couldn't (mocks are instant): gitea's /generate returns and serves reads before the branch ref is writable, so the first content writes 404 "branch does not exist" for a beat — aborting the whole substitution pass. Add waitForBranch (poll BranchExists after generate) + upsertRetry (retry writes on the transient not-found). Test fake now serves the branch readiness probe. Refs #42. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,10 @@ func (f *fakeTemplateServer) handler(t *testing.T, tmpl, dest string) http.Handl
|
||||
_, _ = fmt.Fprintf(w, `{"name":%q,"full_name":"mathias/%s","default_branch":%q,"clone_url":"http://gitea.example.com/mathias/%s.git","html_url":"http://gitea.example.com/mathias/%s","template":false}`,
|
||||
dest, dest, f.genBranch, dest, dest)
|
||||
|
||||
case r.Method == http.MethodGet && strings.HasPrefix(p, "/api/v1/repos/mathias/"+dest+"/branches/"):
|
||||
// waitForBranch readiness probe — branch is present.
|
||||
_, _ = fmt.Fprint(w, `{"name":"main","commit":{"id":"c"}}`)
|
||||
|
||||
case r.Method == http.MethodGet && strings.HasPrefix(p, "/api/v1/repos/mathias/"+dest+"/git/trees/"):
|
||||
var entries []string
|
||||
for path := range f.files {
|
||||
|
||||
Reference in New Issue
Block a user