mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-15 09:02:35 +00:00
fix(worktree): accept missing create payload (#27582)
This commit is contained in:
@@ -166,8 +166,9 @@ export const ExperimentalApi = HttpApi.make("experimental")
|
||||
}),
|
||||
),
|
||||
HttpApiEndpoint.post("worktreeCreate", ExperimentalPaths.worktree, {
|
||||
disableCodecs: true,
|
||||
query: WorkspaceRoutingQuery,
|
||||
payload: Schema.optional(Worktree.CreateInput),
|
||||
payload: Schema.UndefinedOr(Worktree.CreateInput),
|
||||
success: described(Worktree.Info, "Worktree created"),
|
||||
error: WorktreeApiError,
|
||||
}).annotateMerge(
|
||||
|
||||
@@ -129,6 +129,10 @@ function createWorktreeScoped(input: {
|
||||
input.timeoutLabel,
|
||||
input.timeoutMs,
|
||||
)
|
||||
if (response.status !== 200) {
|
||||
const message = yield* Effect.promise(() => response.text())
|
||||
throw new Error(`${input.timeoutLabel} failed: ${response.status} ${message}`)
|
||||
}
|
||||
expect(response.status).toBe(200)
|
||||
const body = yield* json<CreatedWorktree>(response)
|
||||
return { directory: body.directory, body, ready: waitReady(body.directory) } satisfies ScopedWorktree
|
||||
@@ -186,6 +190,46 @@ describe("worktree endpoint reproduction", () => {
|
||||
{ git: true },
|
||||
)
|
||||
|
||||
worktreeTest(
|
||||
"direct HttpApi worktree create accepts missing body",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const server = yield* serverScoped()
|
||||
|
||||
const response = yield* createWorktreeScoped({
|
||||
server,
|
||||
directory: test.directory,
|
||||
path: `${ExperimentalPaths.worktree}?directory=${encodeURIComponent(test.directory)}`,
|
||||
init: { method: "POST", headers: { "content-type": "application/json" } },
|
||||
timeoutLabel: "direct worktree create without body",
|
||||
})
|
||||
|
||||
expect(response).toMatchObject({ directory: expect.any(String) })
|
||||
}),
|
||||
{ git: true },
|
||||
)
|
||||
|
||||
worktreeTest(
|
||||
"direct HttpApi worktree create accepts missing content type and body",
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const server = yield* serverScoped()
|
||||
|
||||
const response = yield* createWorktreeScoped({
|
||||
server,
|
||||
directory: test.directory,
|
||||
path: `${ExperimentalPaths.worktree}?directory=${encodeURIComponent(test.directory)}`,
|
||||
init: { method: "POST" },
|
||||
timeoutLabel: "direct worktree create without content type or body",
|
||||
})
|
||||
|
||||
expect(response).toMatchObject({ directory: expect.any(String) })
|
||||
}),
|
||||
{ git: true },
|
||||
)
|
||||
|
||||
worktreeTest(
|
||||
"workspace worktree create does not hang",
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user