fix wrong herdr response parse + add labels and branch names to delegations
CI / verify (pull_request) Failing after 8s

This commit is contained in:
2026-09-17 21:32:26 +02:00
parent 5cf0beb74b
commit 9494936160
9 changed files with 291 additions and 38 deletions
+21 -6
View File
@@ -109,7 +109,13 @@ export class Herdr {
return matches.length === 1 ? matches[0] : undefined;
}
async create(root: HerdrRoot, base: string, branch: string, signal: AbortSignal) {
async create(
root: HerdrRoot,
base: string,
branch: string,
signal: AbortSignal,
label?: string,
) {
const current = await this.root(root.directory, signal);
if (!current || current.workspaceID !== root.workspaceID || current.repo !== root.repo)
throw new Error("Herdr root workspace is no longer eligible");
@@ -150,6 +156,7 @@ export class Herdr {
branch,
"--base",
commit,
...(label === undefined ? [] : ["--label", label]),
"--no-focus",
],
root.directory,
@@ -185,7 +192,7 @@ export class Herdr {
throw new Error(
"Created checkout does not match the requested repository and base",
);
await this.verify(directory, workspaceID, root.repo, branch, signal);
await this.verify(directory, workspaceID, root, branch, signal);
} catch (error) {
throw new Error(
`Retained Herdr workspace ${workspaceID}, checkout ${directory}, branch ${branch}`,
@@ -198,7 +205,7 @@ export class Herdr {
async verify(
directory: string,
workspaceID: string,
repo: string,
root: HerdrRoot,
branch: string,
signal: AbortSignal,
) {
@@ -214,12 +221,20 @@ export class Herdr {
const checkout = value.result.worktrees.find(
(item) => item.open_workspace_id === workspaceID && item.is_linked_worktree,
);
const sourceCheckout = value.result.worktrees.find(
(item) =>
item.open_workspace_id === value.result.source.source_workspace_id &&
!item.is_linked_worktree &&
!item.is_bare,
);
if (
!checkout ||
value.result.source.source_workspace_id !== workspaceID ||
(await realpath(value.result.source.source_checkout_path)) !== directory ||
!sourceCheckout ||
value.result.source.source_workspace_id !== root.workspaceID ||
(await realpath(value.result.source.source_checkout_path)) !== root.directory ||
(await realpath(sourceCheckout.path)) !== root.directory ||
(await realpath(checkout.path)) !== directory ||
(await realpath(value.result.source.repo_key)) !== repo
(await realpath(value.result.source.repo_key)) !== root.repo
)
throw new Error("Bound Herdr checkout is no longer available");
if (