Skip to content

Conversation

@dylancdavis
Copy link

@dylancdavis dylancdavis commented Sep 15, 2025

(Partially) addresses #566.

Branch names are currently generated from an internally-specified template. This PR adds functionality to specify a template string to generate the branch name from.

Template variables include all variables used in the default template (prefix, entity type, entity number, timestamp). Additional variables include the source branch SHA, the entity's first label, and the entity description (as the first three words in kebab-case).

If the template is unspecified or blank, if the template-generated branch name is blank, or if the generated result conflicts with an existing branch, we fall back to the default template.

This PR does not address functionality for Claude-generated descriptions or from external sources such as Jira.

);

// Check if generated branch already exists on remote
try {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would appreciate some feedback on this- a bare catch block feels like the wrong way to do this.

const branchName = applyBranchTemplate(template, variables);

// Some templates could produce empty results- validate
if (branchName.trim().length > 0) return branchName;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't enforce Kubernetes compatibility for the template case- I figured users that needed it could make their template compatible, and that this way we allow users to specify underscores or uppercase characters in their template if desired.

action.yml Outdated
required: false
default: "claude/"
branch_name_template:
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}}'"
Copy link
Author

@dylancdavis dylancdavis Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new template variables here are label and description, which are admittedly the ones needed for my purposes. I'm avoiding Claude-generated descriptions or variables from external sources (e.g. Jira) for now from simplicity; I'd recommend a separate PR for additional template variables.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only first 3 words? Would be great to have the full title as the branch name eg claude/571-add-custom-branch-name-templates

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like going up to 5 words could be okay?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No solid reason for 3 words. Just personal preference and trying to keep to shorter branch names. 5 words is fine with me

@dylancdavis dylancdavis marked this pull request as ready for review September 17, 2025 02:21
@BOLT04
Copy link

BOLT04 commented Sep 30, 2025

is there a way to get claude to review this PR @dylancdavis , wdyt?

ashwin-ant
ashwin-ant previously approved these changes Oct 1, 2025
action.yml Outdated
required: false
default: "claude/"
branch_name_template:
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}}'"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like going up to 5 words could be okay?

@ashwin-ant
Copy link
Collaborator

Really cool feature, thanks for submitting this! What do you think about making it the description 5 words?

@dylancdavis
Copy link
Author

Updated to 5 words and made it an optional parameter in case we want more flexibility in the future

@tlmader
Copy link

tlmader commented Nov 11, 2025

@ashwin-ant any chance we could get a follow-up review? We really need this functionality!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants