feat(worker): branch type and number rules for task branches
This commit is contained in:
@@ -38,12 +38,29 @@ public sealed class WorktreeManager
|
||||
private Task BroadcastCreating(string taskId) =>
|
||||
_broadcaster?.OperationProgress(taskId, PhaseCreatingWorktree, 0, 0) ?? Task.CompletedTask;
|
||||
|
||||
/// <summary>Branch leaf and folder name for a task worktree: <c>{number}-{title-slug}</c>, unique via the task number.</summary>
|
||||
public static string NameFor(TaskEntity task)
|
||||
/// <summary>
|
||||
/// Branch leaf and folder name: <c>{nummer}-{slug}</c>. Nummer = Ticket-Id, sonst die Task-Nummer —
|
||||
/// außer im Firmen-Repo ohne Ticket, dort sähe sie wie eine Ticket-Id aus und entfällt.
|
||||
/// </summary>
|
||||
public static string NameFor(TaskEntity task, int? ticketId, bool isCompanyRepo)
|
||||
{
|
||||
var titleSlug = CommitMessageBuilder.ToSlug(task.Title);
|
||||
if (titleSlug.Length > 40) titleSlug = titleSlug[..40].TrimEnd('-');
|
||||
return titleSlug.Length == 0 ? task.Number.ToString() : $"{task.Number}-{titleSlug}";
|
||||
var number = ticketId?.ToString() ?? (isCompanyRepo ? null : task.Number.ToString());
|
||||
if (titleSlug.Length == 0) return number ?? task.Number.ToString();
|
||||
return number is null ? titleSlug : $"{number}-{titleSlug}";
|
||||
}
|
||||
|
||||
/// <summary>Branch-Präfix nach work-conventions: <c>feat</c> → <c>feature</c>, Typen ohne eigenes Präfix → <c>chore</c>.</summary>
|
||||
public static string BranchTypeFor(string? commitType)
|
||||
{
|
||||
var t = (commitType ?? "").Trim().ToLowerInvariant();
|
||||
return t switch
|
||||
{
|
||||
"feat" => "feature",
|
||||
"fix" or "refactor" or "docs" or "test" or "chore" => t,
|
||||
_ => "chore",
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<WorktreeContext> CreateAsync(TaskEntity task, ListEntity list, CancellationToken ct)
|
||||
@@ -59,7 +76,7 @@ public sealed class WorktreeManager
|
||||
_logger.LogInformation("Repository at {Dir} had no commits; created an empty bootstrap commit", workingDir);
|
||||
|
||||
var baseCommit = await ResolveBaseCommitAsync(task, workingDir, ct);
|
||||
var name = NameFor(task);
|
||||
var name = NameFor(task, null, false);
|
||||
var slug = CommitMessageBuilder.ToSlug(list.Name);
|
||||
|
||||
string strategy;
|
||||
|
||||
Reference in New Issue
Block a user