use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskBranchesTest method testSuggestBranchName.
public void testSuggestBranchName() {
initRepositories("community", "idea");
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject());
assertEquals(1, handlers.length);
VcsTaskHandler handler = handlers[0];
String startName = "-Hello, this is long name with : and $";
assertFalse(handler.isBranchNameValid(startName));
String cleanUpBranchName = handler.cleanUpBranchName(startName);
assertTrue(handler.isBranchNameValid(cleanUpBranchName));
}
use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskBranchesTest method _testCurrentTasks.
public void _testCurrentTasks() throws Exception {
initRepositories("foo", "bar");
VcsTaskHandler handler = VcsTaskHandler.getAllHandlers(getProject())[0];
VcsTaskHandler.TaskInfo[] tasks = handler.getAllExistingTasks();
assertEquals(1, tasks.length);
VcsTaskHandler.TaskInfo defaultTask = tasks[0];
assertEquals(1, handler.getCurrentTasks().length);
VcsTaskHandler.TaskInfo task = handler.startNewTask("new");
assertEquals(2, handler.getAllExistingTasks().length);
assertEquals(1, handler.getCurrentTasks().length);
handler.closeTask(task, defaultTask);
VcsTaskHandler.TaskInfo[] existingTasks = handler.getAllExistingTasks();
assertEquals(Arrays.asList(existingTasks).toString(), 1, existingTasks.length);
assertEquals(1, handler.getCurrentTasks().length);
}
use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskManagerImpl method createBranch.
public void createBranch(LocalTask task, LocalTask previousActive, String name, @Nullable VcsTaskHandler.TaskInfo branchFrom) {
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
for (VcsTaskHandler handler : handlers) {
VcsTaskHandler.TaskInfo[] info = handler.getCurrentTasks();
if (previousActive != null && previousActive.getBranches(false).isEmpty()) {
addBranches(previousActive, info, false);
}
addBranches(task, info, true);
if (info.length == 0 && branchFrom != null) {
addBranches(task, new VcsTaskHandler.TaskInfo[] { branchFrom }, true);
}
addBranches(task, new VcsTaskHandler.TaskInfo[] { handler.startNewTask(name) }, false);
}
}
use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskBranchesTest method testVcsTaskHandler.
public void testVcsTaskHandler() throws Exception {
List<Repository> repositories = initRepositories("community", "idea");
Repository repository = repositories.get(0);
String defaultBranchName = getDefaultBranchName();
assertEquals(defaultBranchName, repository.getCurrentBranchName());
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject());
assertEquals(1, handlers.length);
VcsTaskHandler handler = handlers[0];
VcsTaskHandler.TaskInfo defaultInfo = handler.getAllExistingTasks()[0];
assertEquals(defaultBranchName, defaultInfo.getName());
assertEquals(2, defaultInfo.getRepositories().size());
final String first = "first";
VcsTaskHandler.TaskInfo firstInfo = handler.startNewTask(first);
repository.update();
assertEquals(first, firstInfo.getName());
assertEquals(2, firstInfo.getRepositories().size());
assertEquals(2, getNumberOfBranches(repository));
assertEquals(first, repository.getCurrentBranchName());
handler.switchToTask(defaultInfo, null);
repository.update();
assertEquals(defaultBranchName, repository.getCurrentBranchName());
final String second = "second";
VcsTaskHandler.TaskInfo secondInfo = handler.startNewTask(second);
repository.update();
assertEquals(3, getNumberOfBranches(repository));
assertEquals(second, repository.getCurrentBranchName());
handler.switchToTask(firstInfo, null);
createAndCommitChanges(repository);
handler.closeTask(secondInfo, firstInfo);
repository.update();
assertEquals(2, getNumberOfBranches(repository));
}
use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.
the class TaskManagerImpl method getAllBranches.
private List<BranchInfo> getAllBranches(final String repo) {
ArrayList<BranchInfo> infos = new ArrayList<>();
VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
for (VcsTaskHandler handler : handlers) {
VcsTaskHandler.TaskInfo[] tasks = handler.getAllExistingTasks();
for (VcsTaskHandler.TaskInfo info : tasks) {
infos.addAll(ContainerUtil.filter(BranchInfo.fromTaskInfo(info, false), info1 -> Comparing.equal(info1.repository, repo)));
}
}
return infos;
}
Aggregations