Customize branch names in Tasks
Answered
I'm writing a plugin for PhpStorm related with Tasks tool, I want to solve some problems related with this.
In the case in question, I would like that given the name of a Task (Changelist), the branch that was created had a certain format (PascalCase for example). However, it is not possible to configure the format of the created branch.
I've been looking at the repository(https://github.com/JetBrains/intellij-community/blob/master/plugins/tasks/tasks-core/src/com/intellij/tasks/actions/vcs/VcsOpenTaskPanel.java#L182) and there doesn't seem to be a way to override the getBranchName
method.
Is there any way, through events, overwriting, overloading... to perform this action?
Please sign in to leave a comment.
Hi mr.cone !
Sorry for the long reply. Yes, we do have
com.intellij.tasks.impl.TaskManagerImpl.Config#branchNameFormat
template for the branch name field. So you can customize it using velocity templates by setting this field's value somewhere in your plugin. Or, you can use a more flexible way to achieve this.- Implement the
com.intellij.tasks.CommitPlaceholderProvider
interface in a similar way:- Register
tasks.commitPlaceholderProvider
in yourplugin.xml
under thecom.intellij
namespace.- Manually replace
${id}
placeholder with your own (we need to tell IDE to use our placeholder instead of the default one).You can do it on IDE startup or in other places.
And that's it. Now you can override branch naming rules as per your wish.