IDEA-112609 Task management: branch name format setting could be provided

This commit is contained in:
Dmitry Avdeev
2014-12-01 17:01:51 +03:00
parent af6e705092
commit b5021b259e
4 changed files with 50 additions and 13 deletions
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.tasks.config.TaskConfigurable">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="8" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="565" height="420"/>
@@ -10,7 +10,7 @@
<children>
<component id="5bcde" class="javax.swing.JTextField" binding="myHistoryLength">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
@@ -20,7 +20,7 @@
</component>
<component id="b5a6c" class="javax.swing.JLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="5bcde"/>
@@ -29,12 +29,12 @@
</component>
<vspacer id="3f700">
<constraints>
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="7" column="1" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="6f93" class="javax.swing.JCheckBox" binding="mySaveContextOnCommit">
<constraints>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&amp;Save context on commit"/>
@@ -60,7 +60,7 @@
</component>
<component id="6010f" class="com.intellij.ui.components.JBCheckBox" binding="myAlwaysDisplayTaskCombo">
<constraints>
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Always &amp;display task combo in toolbar"/>
@@ -68,7 +68,7 @@
</component>
<component id="f47eb" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="c5184"/>
@@ -77,7 +77,7 @@
</component>
<component id="c5184" class="javax.swing.JTextField" binding="myConnectionTimeout">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="50" height="-1"/>
</grid>
</constraints>
@@ -87,7 +87,7 @@
</component>
<component id="737ae" class="javax.swing.JLabel">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="3" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="milliseconds"/>
@@ -96,7 +96,7 @@
<grid id="fa297" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="0" bottom="0" right="0"/>
<constraints>
<grid row="5" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -174,9 +174,26 @@
</grid>
<hspacer id="87f9">
<constraints>
<grid row="5" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="6" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<component id="aa62e" class="com.intellij.ui.components.JBLabel">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<labelFor value="78330"/>
<text value="&amp;Feature branch name format:"/>
</properties>
</component>
<component id="78330" class="javax.swing.JTextField" binding="myBranchNameFormat">
<constraints>
<grid row="1" column="1" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
</form>
@@ -45,9 +45,13 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
@BindControl("changelistNameFormat")
private JTextField myChangelistNameFormat;
private JBCheckBox myAlwaysDisplayTaskCombo;
private JTextField myConnectionTimeout;
@BindControl("branchNameFormat")
private JTextField myBranchNameFormat;
private final Project myProject;
private Configurable[] myConfigurables;
private final NotNullLazyValue<ControlBinder> myControlBinder = new NotNullLazyValue<ControlBinder>() {
@@ -981,8 +981,8 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
}
public String suggestBranchName(Task task) {
if (task.isIssue() && StringUtil.isNotEmpty(task.getNumber())) {
return task.getId().replace(' ', '-');
if (task.isIssue()) {
return TaskUtil.formatTask(task, myConfig.branchNameFormat).replace(' ', '-');
}
else {
String summary = task.getSummary();
@@ -1038,6 +1038,7 @@ public class TaskManagerImpl extends TaskManager implements ProjectComponent, Pe
public boolean markAsInProgress = false;
public String changelistNameFormat = "{id} {summary}";
public String branchNameFormat = "{id}";
public boolean searchClosedTasks = false;
@Tag("servers")
@@ -133,4 +133,19 @@ public class TaskManagerTest extends TaskManagerTestCase {
assertEquals(historyLength, myTaskManager.getLocalTasks().size());
assertEquals(Integer.toString(historyLength + 100 - 1), myTaskManager.getLocalTasks().get(historyLength - 1).getId());
}
public void testBranchNameSuggestion() throws Exception {
TaskTestUtil.TaskBuilder task = new TaskTestUtil.TaskBuilder("IDEA-666", "Bad news", null);
assertEquals("IDEA-666", myTaskManager.suggestBranchName(task));
String format = myTaskManager.getState().branchNameFormat;
try {
myTaskManager.getState().branchNameFormat = "feature/{id}";
assertEquals("feature/IDEA-666", myTaskManager.suggestBranchName(task));
myTaskManager.getState().branchNameFormat = "{id}_{summary}";
assertEquals("IDEA-666_Bad-news", myTaskManager.suggestBranchName(task));
}
finally {
myTaskManager.getState().branchNameFormat = format;
}
}
}