fix(worker): kept worktree in a company repo opens a PR, unexpected ADO/git errors never fail a task start

This commit is contained in:
mika kuns
2026-10-01 12:25:15 +02:00
parent 93fd6740a1
commit 4917533cb4
7 changed files with 54 additions and 13 deletions
@@ -1054,7 +1054,8 @@ public sealed class TaskMergeService
}
}
if (wt is { State: WorktreeState.Active } && _pullRequests is not null
// Kept (parked or reverted) goes the PR way too: a local merge has no place in a company repo.
if (wt is { State: WorktreeState.Active or WorktreeState.Kept } && _pullRequests is not null
&& !string.IsNullOrWhiteSpace(list.WorkingDir)
&& await _pullRequests.IsCompanyRepoAsync(list.WorkingDir, ct))
return await ApproveCompanyAsync(task, list, wt, verifyCommand, ct, progress);
@@ -1164,9 +1165,18 @@ public sealed class TaskMergeService
if (failed is not null) return failed;
}
return await ProgressReporter.RunAsync(
var result = await ProgressReporter.RunAsync(
_pullRequests.PublishAsync(task, list, wt, ranVerify ? verifyCommand : null, ct),
ProgressReportInterval, progress, "push + draft PR running");
// A branch with an open PR is under review again, whatever parked it before.
if (wt.State == WorktreeState.Kept && result.PullRequestUrl is not null)
{
using (var ctx = _dbFactory.CreateDbContext())
await new WorktreeRepository(ctx).SetStateAsync(task.Id, WorktreeState.Active, ct);
await _broadcaster.WorktreeUpdated(task.Id);
}
return result;
}
/// <summary>