Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Nittka2020-03-11 11:01:30 +0000
committerMichael Keppler2020-04-13 10:32:07 +0000
commit0c69c029ccbd0666e4305dac368569d0afca9026 (patch)
treed8c5691c64ed978ce049f51ab1c414e64f20a8b9 /org.eclipse.egit.ui.test/src/org
parent6e4a24687f11f8aa35df385070c324fc359909bb (diff)
downloadegit-0c69c029ccbd0666e4305dac368569d0afca9026.tar.gz
egit-0c69c029ccbd0666e4305dac368569d0afca9026.tar.xz
egit-0c69c029ccbd0666e4305dac368569d0afca9026.zip
allow specifying the tag option when cloning
This change allows the user to specify the tag option for the remote configuration when initially cloning the repository. Bug: 561021 Change-Id: Idd9939d1e90d5eb1b14d3af370d495d4005feb73 Signed-off-by: Alexander Nittka <alex@nittka.de>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java20
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java30
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java18
3 files changed, 63 insertions, 5 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java
index a0c87bdbe2..1c5818ce91 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java
@@ -19,10 +19,12 @@ import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withTe
import static org.eclipse.swtbot.swt.finder.waits.Conditions.waitForWidget;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.widgetIsEnabled;
+import org.eclipse.jgit.transport.TagOpt;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.junit.Assert;
public class RepoRemoteBranchesPage {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
@@ -66,6 +68,24 @@ public class RepoRemoteBranchesPage {
+ errorMessage))), 20000);
}
+ public void selectTagOption(TagOpt option) {
+ int index = 0;
+ switch (option) {
+ case AUTO_FOLLOW:
+ break;
+ case FETCH_TAGS:
+ index = 1;
+ break;
+ case NO_TAGS:
+ index = 2;
+ break;
+ default:
+ Assert.fail("unsupported tag option");
+ break;
+ }
+ bot.radio(index).click();
+ }
+
public void assertNextIsDisabled() {
assertNotEnabled(bot.button("Next >"));
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
index 2d8cc4d91f..50fd73ab3d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.util.List;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
@@ -26,10 +27,13 @@ import org.eclipse.egit.ui.common.RepoRemoteBranchesPage;
import org.eclipse.egit.ui.common.WorkingCopyPage;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.TagOpt;
import org.eclipse.osgi.util.NLS;
+import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
@@ -206,8 +210,32 @@ public class GitCloneWizardTest extends GitCloneWizardTestBase {
RepoRemoteBranchesPage remoteBranches = propertiesPage
.nextToRemoteBranches(r.getUri());
- cloneRepo(destRepo, remoteBranches);
+ Repository cloned = cloneRepo(destRepo, remoteBranches);
bot.button("Cancel").click();
+ List<Ref> tags = cloned.getRefDatabase()
+ .getRefsByPrefix(Constants.R_TAGS);
+ Assert.assertFalse(tags.isEmpty());
+ }
+
+ @Test
+ public void cloneWithTagOption() throws Exception {
+ destRepo = new File(
+ ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(),
+ "test1");
+ tagOptionToSelect = TagOpt.NO_TAGS;
+
+ importWizard.openWizard();
+ RepoPropertiesPage propertiesPage = importWizard
+ .openRepoPropertiesPage();
+
+ RepoRemoteBranchesPage remoteBranches = propertiesPage
+ .nextToRemoteBranches(r.getUri());
+
+ Repository cloned = cloneRepo(destRepo, remoteBranches);
+ bot.button("Cancel").click();
+ List<Ref> tags = cloned.getRefDatabase()
+ .getRefsByPrefix(Constants.R_TAGS);
+ Assert.assertTrue(tags.isEmpty());
}
@Test
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java
index dc89cdebf6..2782fc3d4c 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTestBase.java
@@ -34,6 +34,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.TagOpt;
import org.eclipse.jgit.util.FileUtils;
import org.junit.After;
import org.junit.AfterClass;
@@ -46,6 +47,8 @@ public abstract class GitCloneWizardTestBase extends LocalRepositoryTestCase {
protected static final int NUMBER_RANDOM_COMMITS = 100;
protected GitImportRepoWizard importWizard;
protected File destRepo;
+
+ protected TagOpt tagOptionToSelect = null;
// package private for FindBugs
static SampleTestRepository r;
@AfterClass
@@ -57,12 +60,15 @@ public abstract class GitCloneWizardTestBase extends LocalRepositoryTestCase {
super();
}
- protected void cloneRepo(File destinationRepo,
+ protected Repository cloneRepo(File destinationRepo,
RepoRemoteBranchesPage remoteBranches) throws Exception {
remoteBranches.assertRemoteBranches(SampleTestRepository.FIX,
Constants.MASTER);
remoteBranches.selectBranches(SampleTestRepository.FIX,
Constants.MASTER);
+ if (tagOptionToSelect != null) {
+ remoteBranches.selectTagOption(tagOptionToSelect);
+ }
WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
workingCopy.setDirectory(destinationRepo.toString());
@@ -83,9 +89,12 @@ public abstract class GitCloneWizardTestBase extends LocalRepositoryTestCase {
// and a local master initialized from origin/master (default!)
assertEquals(repository.resolve("master"), repository
.resolve("origin/master"));
- // A well known tag
- assertNotNull(repository.resolve(
- Constants.R_TAGS + SampleTestRepository.v1_0_name).name());
+ if (tagOptionToSelect == null) {
+ // A well known tag, in case the test defines its own tag option
+ assertNotNull(repository
+ .resolve(Constants.R_TAGS + SampleTestRepository.v1_0_name)
+ .name());
+ }
// lots of refs
int refs = repository.getRefDatabase().getRefsByPrefix(RefDatabase.ALL)
.size();
@@ -102,6 +111,7 @@ public abstract class GitCloneWizardTestBase extends LocalRepositoryTestCase {
// No project has been imported
assertEquals(0,
ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
+ return repository;
}
@BeforeClass

Back to the top