diff --git a/README.md b/README.md index 4a56839..04be0c1 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ jobs: | `assignee_trigger` | The assignee username that triggers the action (e.g. @claude). Only used for issue assignment | No | - | | `label_trigger` | The label name that triggers the action when applied to an issue (e.g. "claude") | No | - | | `trigger_phrase` | The trigger phrase to look for in comments, issue/PR bodies, and issue titles | No | `@claude` | +| `branch_prefix` | The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format) | No | `claude/` | | `claude_env` | Custom environment variables to pass to Claude Code execution (YAML format) | No | "" | \*Required when using direct Anthropic API (default and when not using Bedrock or Vertex) diff --git a/action.yml b/action.yml index 3cfa7cf..e9272df 100644 --- a/action.yml +++ b/action.yml @@ -19,6 +19,10 @@ inputs: base_branch: description: "The branch to use as the base/source when creating new branches (defaults to repository default branch)" required: false + branch_prefix: + description: "The prefix to use for Claude branches (defaults to 'claude/', use 'claude-' for dash format)" + required: false + default: "claude/" # Claude Code configuration model: @@ -103,6 +107,7 @@ runs: TRIGGER_PHRASE: ${{ inputs.trigger_phrase }} ASSIGNEE_TRIGGER: ${{ inputs.assignee_trigger }} BASE_BRANCH: ${{ inputs.base_branch }} + BRANCH_PREFIX: ${{ inputs.branch_prefix }} ALLOWED_TOOLS: ${{ inputs.allowed_tools }} DISALLOWED_TOOLS: ${{ inputs.disallowed_tools }} CUSTOM_INSTRUCTIONS: ${{ inputs.custom_instructions }} diff --git a/src/github/context.ts b/src/github/context.ts index 2e92e89..c81ef49 100644 --- a/src/github/context.ts +++ b/src/github/context.ts @@ -35,6 +35,7 @@ export type ParsedGitHubContext = { customInstructions: string; directPrompt: string; baseBranch?: string; + branchPrefix: string; }; }; @@ -60,6 +61,7 @@ export function parseGitHubContext(): ParsedGitHubContext { customInstructions: process.env.CUSTOM_INSTRUCTIONS ?? "", directPrompt: process.env.DIRECT_PROMPT ?? "", baseBranch: process.env.BASE_BRANCH, + branchPrefix: process.env.BRANCH_PREFIX ?? "claude/", }, }; diff --git a/src/github/operations/branch.ts b/src/github/operations/branch.ts index f0b1a95..cf15ba0 100644 --- a/src/github/operations/branch.ts +++ b/src/github/operations/branch.ts @@ -26,7 +26,7 @@ export async function setupBranch( ): Promise { const { owner, repo } = context.repository; const entityNumber = context.entityNumber; - const { baseBranch } = context.inputs; + const { baseBranch, branchPrefix } = context.inputs; const isPR = context.isPR; if (isPR) { @@ -97,7 +97,7 @@ export async function setupBranch( .split("T") .join("_"); - const newBranch = `claude/${entityType}-${entityNumber}-${timestamp}`; + const newBranch = `${branchPrefix}${entityType}-${entityNumber}-${timestamp}`; try { // Get the SHA of the source branch diff --git a/test/mockContext.ts b/test/mockContext.ts index c41146e..8afaba3 100644 --- a/test/mockContext.ts +++ b/test/mockContext.ts @@ -19,6 +19,7 @@ const defaultInputs = { useBedrock: false, useVertex: false, timeoutMinutes: 30, + branchPrefix: "claude/", }; const defaultRepository = { diff --git a/test/permissions.test.ts b/test/permissions.test.ts index a44cfb1..7a7a0c7 100644 --- a/test/permissions.test.ts +++ b/test/permissions.test.ts @@ -67,6 +67,7 @@ describe("checkWritePermissions", () => { disallowedTools: [], customInstructions: "", directPrompt: "", + branchPrefix: "claude/", }, }); diff --git a/test/trigger-validation.test.ts b/test/trigger-validation.test.ts index 36708c0..cbb3796 100644 --- a/test/trigger-validation.test.ts +++ b/test/trigger-validation.test.ts @@ -35,6 +35,7 @@ describe("checkContainsTrigger", () => { allowedTools: [], disallowedTools: [], customInstructions: "", + branchPrefix: "claude/", }, }); expect(checkContainsTrigger(context)).toBe(true); @@ -62,6 +63,7 @@ describe("checkContainsTrigger", () => { allowedTools: [], disallowedTools: [], customInstructions: "", + branchPrefix: "claude/", }, }); expect(checkContainsTrigger(context)).toBe(false); @@ -273,6 +275,7 @@ describe("checkContainsTrigger", () => { allowedTools: [], disallowedTools: [], customInstructions: "", + branchPrefix: "claude/", }, }); expect(checkContainsTrigger(context)).toBe(true); @@ -301,6 +304,7 @@ describe("checkContainsTrigger", () => { allowedTools: [], disallowedTools: [], customInstructions: "", + branchPrefix: "claude/", }, }); expect(checkContainsTrigger(context)).toBe(true); @@ -329,6 +333,7 @@ describe("checkContainsTrigger", () => { allowedTools: [], disallowedTools: [], customInstructions: "", + branchPrefix: "claude/", }, }); expect(checkContainsTrigger(context)).toBe(false);