From ddb3ef092b537e23ad0dc0dce71caeb2029805f3 Mon Sep 17 00:00:00 2001 From: Cole Davis Date: Tue, 16 Sep 2025 21:05:17 -0400 Subject: [PATCH] Merge createBranchTemplateVariables into generateBranchName --- src/utils/branch-template.ts | 39 +++++++++--------------------------- 1 file changed, 9 insertions(+), 30 deletions(-) diff --git a/src/utils/branch-template.ts b/src/utils/branch-template.ts index ed868e5..bfaa81a 100644 --- a/src/utils/branch-template.ts +++ b/src/utils/branch-template.ts @@ -54,30 +54,6 @@ export function applyBranchTemplate( return result; } -/** - * Generates template variables from current context - */ -export function createBranchTemplateVariables( - branchPrefix: string, - entityType: string, - entityNumber: number, - sha?: string, - label?: string, - title?: string, -): BranchTemplateVariables { - const now = new Date(); - - return { - prefix: branchPrefix, - entityType, - entityNumber, - timestamp: `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}-${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}`, - sha: sha?.substring(0, 8), // First 8 characters of SHA - label: label || entityType, // Fall back to entityType if no label - description: title !== undefined ? extractDescription(title) : undefined, - }; -} - /** * Generates a branch name from the provided `template` and set of `variables`. Uses a default format if the template is empty or produces an empty result. */ @@ -90,14 +66,17 @@ export function generateBranchName( label?: string, title?: string, ): string { - const variables = createBranchTemplateVariables( - branchPrefix, + const now = new Date(); + + const variables: BranchTemplateVariables = { + prefix: branchPrefix, entityType, entityNumber, - sha, - label, - title, - ); + timestamp: `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, "0")}${String(now.getDate()).padStart(2, "0")}-${String(now.getHours()).padStart(2, "0")}${String(now.getMinutes()).padStart(2, "0")}`, + sha: sha?.substring(0, 8), // First 8 characters of SHA + label: label || entityType, // Fall back to entityType if no label + description: title ? extractDescription(title) : undefined, + }; if (template?.trim()) { const branchName = applyBranchTemplate(template, variables);