mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
Remove more granular time template variables
This commit is contained in:
@@ -24,7 +24,7 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: "claude/"
|
default: "claude/"
|
||||||
branch_name_template:
|
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
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
allowed_bots:
|
allowed_bots:
|
||||||
|
|||||||
@@ -28,11 +28,6 @@ export interface BranchTemplateVariables {
|
|||||||
entityType: string;
|
entityType: string;
|
||||||
entityNumber: number;
|
entityNumber: number;
|
||||||
timestamp: string;
|
timestamp: string;
|
||||||
year: string;
|
|
||||||
month: string;
|
|
||||||
day: string;
|
|
||||||
hour: string;
|
|
||||||
minute: string;
|
|
||||||
sha?: string;
|
sha?: string;
|
||||||
label?: string;
|
label?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
@@ -77,11 +72,6 @@ export function createBranchTemplateVariables(
|
|||||||
entityType,
|
entityType,
|
||||||
entityNumber,
|
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")}`,
|
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
|
sha: sha?.substring(0, 8), // First 8 characters of SHA
|
||||||
label: label || entityType, // Fall back to entityType if no label
|
label: label || entityType, // Fall back to entityType if no label
|
||||||
description: title !== undefined ? extractDescription(title) : undefined,
|
description: title !== undefined ? extractDescription(title) : undefined,
|
||||||
|
|||||||
@@ -17,11 +17,6 @@ describe("branch template utilities", () => {
|
|||||||
entityType: "issue",
|
entityType: "issue",
|
||||||
entityNumber: 123,
|
entityNumber: 123,
|
||||||
timestamp: "20240301-1430",
|
timestamp: "20240301-1430",
|
||||||
year: "2024",
|
|
||||||
month: "03",
|
|
||||||
day: "01",
|
|
||||||
hour: "14",
|
|
||||||
minute: "30",
|
|
||||||
sha: "abcd1234",
|
sha: "abcd1234",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,22 +26,17 @@ describe("branch template utilities", () => {
|
|||||||
|
|
||||||
it("should handle custom templates with multiple variables", () => {
|
it("should handle custom templates with multiple variables", () => {
|
||||||
const template =
|
const template =
|
||||||
"{{prefix}}fix/{{entityType}}_{{entityNumber}}_{{year}}{{month}}{{day}}_{{sha}}";
|
"{{prefix}}fix/{{entityType}}_{{entityNumber}}_{{timestamp}}_{{sha}}";
|
||||||
const variables = {
|
const variables = {
|
||||||
prefix: "claude-",
|
prefix: "claude-",
|
||||||
entityType: "pr",
|
entityType: "pr",
|
||||||
entityNumber: 456,
|
entityNumber: 456,
|
||||||
timestamp: "20240301-1430",
|
timestamp: "20240301-1430",
|
||||||
year: "2024",
|
|
||||||
month: "03",
|
|
||||||
day: "01",
|
|
||||||
hour: "14",
|
|
||||||
minute: "30",
|
|
||||||
sha: "abcd1234",
|
sha: "abcd1234",
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = applyBranchTemplate(template, variables);
|
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", () => {
|
it("should handle templates with missing variables gracefully", () => {
|
||||||
@@ -56,11 +46,6 @@ describe("branch template utilities", () => {
|
|||||||
entityType: "issue",
|
entityType: "issue",
|
||||||
entityNumber: 123,
|
entityNumber: 123,
|
||||||
timestamp: "20240301-1430",
|
timestamp: "20240301-1430",
|
||||||
year: "2024",
|
|
||||||
month: "03",
|
|
||||||
day: "01",
|
|
||||||
hour: "14",
|
|
||||||
minute: "30",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const result = applyBranchTemplate(template, variables);
|
const result = applyBranchTemplate(template, variables);
|
||||||
@@ -83,11 +68,6 @@ describe("branch template utilities", () => {
|
|||||||
expect(result.sha).toBe("abcdef12");
|
expect(result.sha).toBe("abcdef12");
|
||||||
expect(result.label).toBe("issue"); // fallback to entityType
|
expect(result.label).toBe("issue"); // fallback to entityType
|
||||||
expect(result.timestamp).toMatch(/^\d{8}-\d{4}$/);
|
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", () => {
|
it("should handle SHA truncation", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user