mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-155327 Improvement to automated Branch Name in the Open Task dialog
added option to replace spaces with custom character GitOrigin-RevId: 30b21986da5df933addcb30ae62646becda94307
This commit is contained in:
committed by
intellij-monorepo-bot
parent
72a4e0fd27
commit
1d13116e16
@@ -974,12 +974,17 @@ public final class TaskManagerImpl extends TaskManager implements PersistentStat
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String suggestBranchName(@NotNull Task task) {
|
||||
public String suggestBranchName(@NotNull Task task, String separator) {
|
||||
String name = constructDefaultBranchName(task);
|
||||
if (task.isIssue()) return name.replace(' ', '-');
|
||||
if (task.isIssue()) return name.replace(" ", separator);
|
||||
List<String> words = StringUtil.getWordsIn(name);
|
||||
String[] strings = ArrayUtilRt.toStringArray(words);
|
||||
return StringUtil.join(strings, 0, Math.min(2, strings.length), "-");
|
||||
return StringUtil.join(strings, 0, Math.min(2, strings.length), separator);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String suggestBranchName(@NotNull Task task) {
|
||||
return suggestBranchName(task, "-");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -16,6 +16,7 @@ public class TaskSettings implements PersistentStateComponent<TaskSettings> {
|
||||
public boolean ALWAYS_DISPLAY_COMBO = false;
|
||||
public int CONNECTION_TIMEOUT = 5000;
|
||||
public boolean LOWER_CASE_BRANCH = false;
|
||||
public String REPLACE_SPACES = "-";
|
||||
|
||||
public static TaskSettings getInstance() {
|
||||
return ServiceManager.getService(TaskSettings.class);
|
||||
|
||||
@@ -170,9 +170,9 @@ public class VcsOpenTaskPanel extends TaskDialogPanel {
|
||||
|
||||
@NotNull
|
||||
private String getBranchName(Task task) {
|
||||
String branchName = myVcsTaskHandler != null
|
||||
? myVcsTaskHandler.cleanUpBranchName(myTaskManager.constructDefaultBranchName(task))
|
||||
: myTaskManager.suggestBranchName(task);
|
||||
String branchName = myTaskManager.suggestBranchName(task, StringUtil.notNullize(TaskSettings.getInstance().REPLACE_SPACES));
|
||||
if (myVcsTaskHandler != null)
|
||||
myVcsTaskHandler.cleanUpBranchName(branchName);
|
||||
return TaskSettings.getInstance().LOWER_CASE_BRANCH ? StringUtil.toLowerCase(branchName) : branchName;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<properties>
|
||||
<anchor value=""/>
|
||||
<labelFor value="ef62"/>
|
||||
<text value="Changelist name &format:"/>
|
||||
<text value="&Changelist name format:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ef62" class="com.intellij.ui.EditorTextField" binding="myChangelistNameFormat" custom-create="true">
|
||||
@@ -117,7 +117,7 @@
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Enable &cache"/>
|
||||
<text value="&Enable cache"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="a1a54">
|
||||
@@ -192,14 +192,48 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c6d76" class="javax.swing.JCheckBox" binding="myLowerCase">
|
||||
<grid id="acd61" layout-manager="GridLayoutManager" row-count="1" 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>
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="1" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Lo&wercased"/>
|
||||
</properties>
|
||||
</component>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="c6d76" class="javax.swing.JCheckBox" binding="myLowerCase">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Lo&wercased"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="21872" class="com.intellij.ui.components.JBLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="154" height="16"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Replace spaces with"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7c703" class="com.intellij.ui.components.JBTextField" binding="myReplaceSpaces">
|
||||
<constraints>
|
||||
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<columns value="1"/>
|
||||
<text value="-"/>
|
||||
</properties>
|
||||
</component>
|
||||
<hspacer id="84b4f">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.PopupStep;
|
||||
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.tasks.CommitPlaceholderProvider;
|
||||
import com.intellij.tasks.TaskManager;
|
||||
@@ -26,6 +27,7 @@ import com.intellij.tasks.impl.TaskManagerImpl;
|
||||
import com.intellij.ui.EditorTextField;
|
||||
import com.intellij.ui.ExtendableEditorSupport;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.ui.components.JBTextField;
|
||||
import com.intellij.ui.components.fields.ExtendableTextComponent;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -71,6 +73,7 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
|
||||
@BindControl("branchNameFormat")
|
||||
private EditorTextField myBranchNameFormat;
|
||||
private JCheckBox myLowerCase;
|
||||
private JBTextField myReplaceSpaces;
|
||||
|
||||
private final Project myProject;
|
||||
private Configurable[] myConfigurables;
|
||||
@@ -114,6 +117,7 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
|
||||
myAlwaysDisplayTaskCombo.setSelected(TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO);
|
||||
myConnectionTimeout.setText(Integer.toString(TaskSettings.getInstance().CONNECTION_TIMEOUT));
|
||||
myLowerCase.setSelected(TaskSettings.getInstance().LOWER_CASE_BRANCH);
|
||||
myReplaceSpaces.setText(TaskSettings.getInstance().REPLACE_SPACES);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,6 +139,7 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
|
||||
Integer connectionTimeout = Integer.valueOf(myConnectionTimeout.getText());
|
||||
TaskSettings.getInstance().CONNECTION_TIMEOUT = connectionTimeout;
|
||||
TaskSettings.getInstance().LOWER_CASE_BRANCH = myLowerCase.isSelected();
|
||||
TaskSettings.getInstance().REPLACE_SPACES = myReplaceSpaces.getText();
|
||||
|
||||
if (connectionTimeout != oldConnectionTimeout) {
|
||||
for (TaskRepository repository : manager.getAllRepositories()) {
|
||||
@@ -150,7 +155,8 @@ public class TaskConfigurable extends BindableConfigurable implements Searchable
|
||||
return super.isModified() ||
|
||||
TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO != myAlwaysDisplayTaskCombo.isSelected() ||
|
||||
TaskSettings.getInstance().CONNECTION_TIMEOUT != Integer.valueOf(myConnectionTimeout.getText()) ||
|
||||
TaskSettings.getInstance().LOWER_CASE_BRANCH != myLowerCase.isSelected();
|
||||
TaskSettings.getInstance().LOWER_CASE_BRANCH != myLowerCase.isSelected() ||
|
||||
!Comparing.equal(TaskSettings.getInstance().REPLACE_SPACES, myLowerCase.getText());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -421,6 +421,7 @@ public class TaskVcsTest extends CodeInsightFixtureTestCase {
|
||||
|
||||
LocalTaskImpl strange = new LocalTaskImpl("1", "very long and strange summary");
|
||||
assertEquals("very-long", myTaskManager.suggestBranchName(strange));
|
||||
assertEquals("very_long", myTaskManager.suggestBranchName(strange, "_"));
|
||||
|
||||
myTaskManager.getState().branchNameFormat = "{id} {summary}";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user