mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Merge createBranchTemplateVariables into generateBranchName
This commit is contained in:
@@ -54,30 +54,6 @@ export function applyBranchTemplate(
|
|||||||
return result;
|
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.
|
* 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,
|
label?: string,
|
||||||
title?: string,
|
title?: string,
|
||||||
): string {
|
): string {
|
||||||
const variables = createBranchTemplateVariables(
|
const now = new Date();
|
||||||
branchPrefix,
|
|
||||||
|
const variables: BranchTemplateVariables = {
|
||||||
|
prefix: branchPrefix,
|
||||||
entityType,
|
entityType,
|
||||||
entityNumber,
|
entityNumber,
|
||||||
sha,
|
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")}`,
|
||||||
label,
|
sha: sha?.substring(0, 8), // First 8 characters of SHA
|
||||||
title,
|
label: label || entityType, // Fall back to entityType if no label
|
||||||
);
|
description: title ? extractDescription(title) : undefined,
|
||||||
|
};
|
||||||
|
|
||||||
if (template?.trim()) {
|
if (template?.trim()) {
|
||||||
const branchName = applyBranchTemplate(template, variables);
|
const branchName = applyBranchTemplate(template, variables);
|
||||||
|
|||||||
Reference in New Issue
Block a user