diff options
author | Thomas Wolf | 2015-10-17 19:48:55 +0000 |
---|---|---|
committer | Thomas Wolf | 2015-10-26 07:12:32 +0000 |
commit | dc38a45eb1ff64d74335a40a08d84814b9d9f11f (patch) | |
tree | 74e05071f31662d1c7a39f7c36b4dfa1c5850754 | |
parent | 7161642f7f51214360ecb91ea58026a075d20f73 (diff) | |
download | egit-dc38a45eb1ff64d74335a40a08d84814b9d9f11f.tar.gz egit-dc38a45eb1ff64d74335a40a08d84814b9d9f11f.tar.xz egit-dc38a45eb1ff64d74335a40a08d84814b9d9f11f.zip |
Don't delete projects on disk unless the user said so
If the user chooses not to delete the working tree when deleting a
repository the projects from that repository must not be deleted but
only removed from the workspace if the "Remove projects from workspace"
option is checked.
(Backport of commit 0c7c118.)
Bug: 479964
Change-Id: I4435d049703f207224b0847a20742d240483abdf
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2 files changed, 45 insertions, 3 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java index aa6ebb1645..93269f6400 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/view/repositories/GitRepositoriesViewRepoDeletionTest.java @@ -10,6 +10,7 @@ package org.eclipse.egit.ui.view.repositories; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.File; @@ -22,6 +23,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jgit.api.SubmoduleAddCommand; import org.eclipse.jgit.lib.Repository; import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree; import org.junit.Before; @@ -79,6 +81,45 @@ public class GitRepositoriesViewRepoDeletionTest extends } @Test + public void testDeleteRepositoryKeepProjectsBug479964() throws Exception { + deleteAllProjects(); + assertProjectExistence(PROJ1, false); + clearView(); + Activator.getDefault().getRepositoryUtil() + .addConfiguredRepository(repositoryFile); + shareProjects(repositoryFile); + assertProjectExistence(PROJ1, true); + refreshAndWait(); + assertHasRepo(repositoryFile); + SWTBotTree tree = getOrOpenView().bot().tree(); + tree.getAllItems()[0].select(); + ContextMenuHelper.clickContextMenu(tree, myUtil + .getPluginLocalizedValue(DELETE_REPOSITORY_CONTEXT_MENU_LABEL)); + SWTBotShell shell = bot.shell( + UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryWindowTitle); + shell.activate(); + shell.bot() + .checkBox( + UIText.DeleteRepositoryConfirmDialog_DeleteGitDirCheckbox) + .select(); + SWTBotCheckBox checkbox = shell.bot().checkBox( + UIText.DeleteRepositoryConfirmDialog_DeleteWorkingDirectoryCheckbox); + checkbox.select(); + checkbox.deselect(); + // Now "Remove project from workspace" is selected, but "Delete working + // tree" is not. + shell.bot().button(IDialogConstants.OK_LABEL).click(); + TestUtil.joinJobs(JobFamilies.REPOSITORY_DELETE); + + refreshAndWait(); + assertEmpty(); + assertProjectExistence(PROJ1, false); + assertFalse(repositoryFile.exists()); + assertTrue( + new File(repositoryFile.getParentFile(), PROJ1).isDirectory()); + } + + @Test public void testDeleteSubmoduleRepository() throws Exception { deleteAllProjects(); assertProjectExistence(PROJ1, false); diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java index ce346a0cfe..b2f0dfb5b3 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/RemoveCommand.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2013 SAP AG and others. + * Copyright (c) 2010, 2013, 2015 SAP AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -8,7 +8,8 @@ * Contributors: * Mathias Kinzler (SAP AG) - initial implementation * Daniel Megert <daniel_megert@ch.ibm.com> - Delete empty working directory - * Laurent Goubet <laurent.goubet@obeo.fr - 404121 + * Laurent Goubet <laurent.goubet@obeo.fr> - Bug 404121 + * Thomas Wolf <thomas.wolf@paranor.ch> - Bug 479964 *******************************************************************************/ package org.eclipse.egit.ui.internal.repository.tree.command; @@ -155,7 +156,7 @@ public class RemoveCommand extends if (removeProj) { // confirmed deletion - deleteProjects(delete, projectsToDelete, + deleteProjects(deleteWorkDir, projectsToDelete, monitor); } for (RepositoryNode node : selectedNodes) { |