-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add custom branch name templates #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
dd364b7 to
35c0ca2
Compare
75ba2eb to
b129570
Compare
| ); | ||
|
|
||
| // Check if generated branch already exists on remote | ||
| try { |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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}}'" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
is there a way to get claude to review this PR @dylancdavis , wdyt? |
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}}'" |
There was a problem hiding this comment.
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?
|
Really cool feature, thanks for submitting this! What do you think about making it the description 5 words? |
|
Updated to 5 words and made it an optional parameter in case we want more flexibility in the future |
|
@ashwin-ant any chance we could get a follow-up review? We really need this functionality! |
(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.