Search in sources :

Example 1 with WorkingCopyPage

use of org.eclipse.egit.ui.common.WorkingCopyPage in project egit by eclipse.

the class GitCloneWizardTest method alteringSomeParametersDuringClone.

@Test
public void alteringSomeParametersDuringClone() throws Exception {
    destRepo = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), "test2");
    importWizard.openWizard();
    RepoPropertiesPage repoProperties = importWizard.openRepoPropertiesPage();
    RepoRemoteBranchesPage remoteBranches = repoProperties.nextToRemoteBranches(r.getUri());
    remoteBranches.deselectAllBranches();
    remoteBranches.assertErrorMessage("At least one branch must be selected.");
    remoteBranches.assertNextIsDisabled();
    remoteBranches.selectBranches(SampleTestRepository.FIX);
    remoteBranches.assertNextIsEnabled();
    WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
    workingCopy.setDirectory(destRepo.toString());
    workingCopy.assertBranch(SampleTestRepository.FIX);
    workingCopy.setRemoteName("src");
    workingCopy.waitForCreate();
    // Some random sampling to see we got something. We do not test
    // the integrity of the repository here. Only a few basic properties
    // we'd expect from a clone made this way, that would possibly
    // not hold true given other parameters in the GUI.
    Repository repository = FileRepositoryBuilder.create(new File(destRepo, Constants.DOT_GIT));
    assertNotNull(repository.resolve("src/" + SampleTestRepository.FIX));
    // we didn't clone that one
    assertNull(repository.resolve("src/master"));
    // and a local master initialized from origin/master (default!)
    assertEquals(repository.resolve("stable"), repository.resolve("src/stable"));
    // A well known tag
    assertNotNull(repository.resolve(Constants.R_TAGS + SampleTestRepository.v2_0_name).name());
    // lots of refs
    assertTrue(repository.getAllRefs().size() >= 4);
    bot.button("Cancel").click();
}
Also used : Repository(org.eclipse.jgit.lib.Repository) RepoPropertiesPage(org.eclipse.egit.ui.common.RepoPropertiesPage) RepoRemoteBranchesPage(org.eclipse.egit.ui.common.RepoRemoteBranchesPage) WorkingCopyPage(org.eclipse.egit.ui.common.WorkingCopyPage) File(java.io.File) Test(org.junit.Test)

Example 2 with WorkingCopyPage

use of org.eclipse.egit.ui.common.WorkingCopyPage in project egit by eclipse.

the class GitCloneWizardTest method clonedRepositoryShouldExistOnFileSystem.

@Test
public void clonedRepositoryShouldExistOnFileSystem() throws Exception {
    importWizard.openWizard();
    RepoPropertiesPage repoProperties = importWizard.openRepoPropertiesPage();
    RepoRemoteBranchesPage remoteBranches = repoProperties.nextToRemoteBranches(r.getUri());
    remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
    WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
    workingCopy.assertWorkingCopyExists();
    bot.button("Cancel").click();
}
Also used : RepoPropertiesPage(org.eclipse.egit.ui.common.RepoPropertiesPage) RepoRemoteBranchesPage(org.eclipse.egit.ui.common.RepoRemoteBranchesPage) WorkingCopyPage(org.eclipse.egit.ui.common.WorkingCopyPage) Test(org.junit.Test)

Example 3 with WorkingCopyPage

use of org.eclipse.egit.ui.common.WorkingCopyPage in project egit by eclipse.

the class GitCloneWizardTestBase method cloneRepo.

protected void cloneRepo(File destinationRepo, RepoRemoteBranchesPage remoteBranches) throws Exception {
    remoteBranches.assertRemoteBranches(SampleTestRepository.FIX, Constants.MASTER);
    remoteBranches.selectBranches(SampleTestRepository.FIX, Constants.MASTER);
    WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
    workingCopy.setDirectory(destinationRepo.toString());
    workingCopy.assertDirectory(destinationRepo.toString());
    workingCopy.assertBranch(Constants.MASTER);
    workingCopy.assertRemoteName(Constants.DEFAULT_REMOTE_NAME);
    workingCopy.waitForCreate();
    // Some random sampling to see we got something. We do not test
    // the integrity of the repository here. Only a few basic properties
    // we'd expect from a clone made this way, that would possibly
    // not hold true given other parameters in the GUI.
    Repository repository = FileRepositoryBuilder.create(new File(destinationRepo, Constants.DOT_GIT));
    // we always have an origin/master
    assertNotNull(repository.resolve("origin/master"));
    // 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());
    // lots of refs
    int refs = repository.getAllRefs().size();
    assertTrue(refs >= 4);
    // and a known file in the working dir
    assertTrue(new File(destinationRepo, SampleTestRepository.A_txt_name).exists());
    DirCacheEntry fileEntry = null;
    DirCache dc = repository.lockDirCache();
    fileEntry = dc.getEntry(SampleTestRepository.A_txt_name);
    dc.unlock();
    // check that we have the file in the index
    assertNotNull(fileEntry);
    // No project has been imported
    assertEquals(0, ResourcesPlugin.getWorkspace().getRoot().getProjects().length);
}
Also used : DirCache(org.eclipse.jgit.dircache.DirCache) Repository(org.eclipse.jgit.lib.Repository) DirCacheEntry(org.eclipse.jgit.dircache.DirCacheEntry) WorkingCopyPage(org.eclipse.egit.ui.common.WorkingCopyPage) File(java.io.File)

Aggregations

WorkingCopyPage (org.eclipse.egit.ui.common.WorkingCopyPage)3 File (java.io.File)2 RepoPropertiesPage (org.eclipse.egit.ui.common.RepoPropertiesPage)2 RepoRemoteBranchesPage (org.eclipse.egit.ui.common.RepoRemoteBranchesPage)2 Repository (org.eclipse.jgit.lib.Repository)2 Test (org.junit.Test)2 DirCache (org.eclipse.jgit.dircache.DirCache)1 DirCacheEntry (org.eclipse.jgit.dircache.DirCacheEntry)1