feat(worker): fast-forward finished children into the parent's unit branch
Planning parents get their own worktree on Queue plan, children fork from the unit head and are absorbed via merge --ff-only before Done (ff failure -> Failed, interactive child approve -> absorb instead of merge to the target).
This commit is contained in:
@@ -256,23 +256,19 @@ public sealed class WorktreeManager
|
||||
return TicketStatusMap.ParseBandelTicketId(parentRef);
|
||||
}
|
||||
|
||||
// Improvement children (parent is a non-planning task with its own worktree) branch
|
||||
// from the parent's recorded HEAD so they build on the parent's not-yet-merged work.
|
||||
// Planning children and standalone tasks base off list_config.base_branch, else the current HEAD.
|
||||
/// <summary>
|
||||
/// A child of a parent with an Active worktree starts from the unit branch's current head, so it
|
||||
/// sees every sibling absorbed before it. Unit roots (and legacy children) base off
|
||||
/// <c>list_config.base_branch</c>, else the current HEAD.
|
||||
/// </summary>
|
||||
private async Task<string> ResolveBaseCommitAsync(TaskEntity task, string workingDir, CancellationToken ct)
|
||||
{
|
||||
if (task.ParentTaskId is not null)
|
||||
{
|
||||
using var ctx = _dbFactory.CreateDbContext();
|
||||
var parent = await ctx.Tasks.AsNoTracking()
|
||||
.FirstOrDefaultAsync(t => t.Id == task.ParentTaskId, ct);
|
||||
if (parent is not null && parent.PlanningPhase == PlanningPhase.None)
|
||||
{
|
||||
var parentWt = await new WorktreeRepository(ctx).GetByTaskIdAsync(task.ParentTaskId, ct);
|
||||
var parentHead = parentWt?.HeadCommit ?? parentWt?.BaseCommit;
|
||||
if (parentHead is not null)
|
||||
return parentHead;
|
||||
}
|
||||
var parentWt = await new WorktreeRepository(ctx).GetByTaskIdAsync(task.ParentTaskId, ct);
|
||||
if (parentWt is { State: WorktreeState.Active })
|
||||
return await _git.RevParseAsync(workingDir, parentWt.BranchName, ct);
|
||||
}
|
||||
using var cfgCtx = _dbFactory.CreateDbContext();
|
||||
var baseBranch = await cfgCtx.ListConfigs.AsNoTracking()
|
||||
|
||||
Reference in New Issue
Block a user