Add check for empty template-generated name

This commit is contained in:
Cole Davis
2025-09-16 20:50:52 -04:00
parent e758a32de7
commit 1a49e00b3e

View File

@@ -99,20 +99,19 @@ export function generateBranchName(
title, title,
); );
let branchName: string; if (template?.trim()) {
const branchName = applyBranchTemplate(template, variables);
if (template && template.trim()) { // Return generated name if non-empty
// Use custom template if (branchName.trim().length > 0) return branchName;
branchName = applyBranchTemplate(template, variables);
} else { // Log fallback when custom template produces empty result
// Use default format (backward compatibility) console.log(
branchName = `${branchPrefix}${entityType}-${entityNumber}-${variables.timestamp}`; `Branch template '${template}' generated empty result, falling back to default format`,
);
} }
// Ensure branch name is Kubernetes-compatible: const branchName = `${branchPrefix}${entityType}-${entityNumber}-${variables.timestamp}`;
// - Lowercase only // Kubernetes compatible: lowercase, max 50 chars, alphanumeric and hyphens only
// - Alphanumeric with hyphens
// - No underscores
// - Max 50 chars (to allow for prefixes)
return branchName.toLowerCase().substring(0, 50); return branchName.toLowerCase().substring(0, 50);
} }