diff --git a/action.yml b/action.yml index 5ab8877..12c75fe 100644 --- a/action.yml +++ b/action.yml @@ -24,7 +24,7 @@ inputs: required: false default: "claude/" branch_name_template: - description: "Template for branch naming. Available variables: {{prefix}}, {{entityType}}, {{entityNumber}}, {{timestamp}}, {{year}}, {{month}}, {{day}}, {{hour}}, {{minute}}, {{sha}}, {{label}}, {{description}}. {{label}} will be first label from the issue/PR, or {{entityType}} as a fallback. {{description}} will be the first 3 words of the issue/PR title in kebab-case. Default: '{{prefix}}{{entityType}}-{{entityNumber}}-{{timestamp}}'" + description: "Template for branch naming. Available variables: {{prefix}}, {{entityType}}, {{entityNumber}}, {{timestamp}}, {{sha}}, {{label}}, {{description}}. {{label}} will be first label from the issue/PR, or {{entityType}} as a fallback. {{description}} will be the first 3 words of the issue/PR title in kebab-case. Default: '{{prefix}}{{entityType}}-{{entityNumber}}-{{timestamp}}'" required: false default: "" allowed_bots: diff --git a/src/utils/branch-template.ts b/src/utils/branch-template.ts index 5839c92..0d5a34e 100644 --- a/src/utils/branch-template.ts +++ b/src/utils/branch-template.ts @@ -28,11 +28,6 @@ export interface BranchTemplateVariables { entityType: string; entityNumber: number; timestamp: string; - year: string; - month: string; - day: string; - hour: string; - minute: string; sha?: string; label?: string; description?: string; @@ -77,11 +72,6 @@ export function createBranchTemplateVariables( 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")}`, - year: String(now.getFullYear()), - month: String(now.getMonth() + 1).padStart(2, "0"), - day: String(now.getDate()).padStart(2, "0"), - hour: String(now.getHours()).padStart(2, "0"), - minute: 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, diff --git a/test/branch-template.test.ts b/test/branch-template.test.ts index ce8a966..d70bc88 100644 --- a/test/branch-template.test.ts +++ b/test/branch-template.test.ts @@ -17,11 +17,6 @@ describe("branch template utilities", () => { entityType: "issue", entityNumber: 123, timestamp: "20240301-1430", - year: "2024", - month: "03", - day: "01", - hour: "14", - minute: "30", sha: "abcd1234", }; @@ -31,22 +26,17 @@ describe("branch template utilities", () => { it("should handle custom templates with multiple variables", () => { const template = - "{{prefix}}fix/{{entityType}}_{{entityNumber}}_{{year}}{{month}}{{day}}_{{sha}}"; + "{{prefix}}fix/{{entityType}}_{{entityNumber}}_{{timestamp}}_{{sha}}"; const variables = { prefix: "claude-", entityType: "pr", entityNumber: 456, timestamp: "20240301-1430", - year: "2024", - month: "03", - day: "01", - hour: "14", - minute: "30", sha: "abcd1234", }; const result = applyBranchTemplate(template, variables); - expect(result).toBe("claude-fix/pr_456_20240301_abcd1234"); + expect(result).toBe("claude-fix/pr_456_20240301-1430_abcd1234"); }); it("should handle templates with missing variables gracefully", () => { @@ -56,11 +46,6 @@ describe("branch template utilities", () => { entityType: "issue", entityNumber: 123, timestamp: "20240301-1430", - year: "2024", - month: "03", - day: "01", - hour: "14", - minute: "30", }; const result = applyBranchTemplate(template, variables); @@ -83,11 +68,6 @@ describe("branch template utilities", () => { expect(result.sha).toBe("abcdef12"); expect(result.label).toBe("issue"); // fallback to entityType expect(result.timestamp).toMatch(/^\d{8}-\d{4}$/); - expect(result.year).toMatch(/^\d{4}$/); - expect(result.month).toMatch(/^\d{2}$/); - expect(result.day).toMatch(/^\d{2}$/); - expect(result.hour).toMatch(/^\d{2}$/); - expect(result.minute).toMatch(/^\d{2}$/); }); it("should handle SHA truncation", () => {