Search in sources :

Example 11 with TestRepository

use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.

the class AddOperationTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) File(java.io.File) IFile(org.eclipse.core.resources.IFile) Before(org.junit.Before)

Example 12 with TestRepository

use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.

the class BranchOperationTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    testRepository = new TestRepository(gitDir);
    repository = testRepository.getRepository();
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) Before(org.junit.Before)

Example 13 with TestRepository

use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.

the class DeletePathsOperationTest method setUp.

@Before
public void setUp() throws Exception {
    workdir = testUtils.createTempDir("Repository1");
    repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));
    project = testUtils.createProjectInLocalFileSystem(workdir, projectName);
    repository1.connect(project);
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) File(java.io.File) Before(org.junit.Before)

Example 14 with TestRepository

use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.

the class DiscardChangesOperationTest method setUp.

@Before
public void setUp() throws Exception {
    workdir = testUtils.createTempDir("Repository1");
    repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));
    // now we create a project in repo1
    project = testUtils.createProjectInLocalFileSystem(workdir, projectName);
    testUtils.addFileToProject(project, "folder1/file1.txt", "Hello world 1");
    testUtils.addFileToProject(project, "folder1/file2.txt", "Hello world 2");
    repository1.connect(project);
    repository1.trackAllFiles(project);
    repository1.commit("Initial commit");
    File workdir2 = testUtils.createTempDir("Project2");
    // Project location is at root of repository
    project2 = testUtils.createProjectInLocalFileSystem(workdir2.getParentFile(), "Project2");
    testUtils.addFileToProject(project2, "file.txt", "initial");
    repository2 = new TestRepository(new File(workdir2, Constants.DOT_GIT));
    repository2.connect(project2);
    repository2.trackAllFiles(project2);
    repository2.commit("Initial commit");
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) File(java.io.File) IFile(org.eclipse.core.resources.IFile) Before(org.junit.Before)

Example 15 with TestRepository

use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.

the class SubmoduleFolderTest method setUp.

@Before
public void setUp() throws Exception {
    parentRepositoryGitDir = createProjectAndCommitToRepository();
    childRepositoryGitDir = createProjectAndCommitToRepository(CHILDREPO, CHILDPROJECT);
    Activator.getDefault().getRepositoryUtil().addConfiguredRepository(parentRepositoryGitDir);
    parentRepository = lookupRepository(parentRepositoryGitDir);
    childRepository = lookupRepository(childRepositoryGitDir);
    parentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
    IFolder folder = parentProject.getFolder(FOLDER);
    IFolder subfolder = folder.getFolder(SUBFOLDER);
    subfolder.create(false, true, null);
    assertTrue(subfolder.exists());
    IFile someFile = subfolder.getFile("dummy.txt");
    touch(PROJ1, someFile.getProjectRelativePath().toOSString(), "Dummy content");
    addAndCommit(someFile, "Commit sub/dummy.txt");
    childFolder = subfolder.getFolder(CHILD);
    Git.wrap(parentRepository).submoduleAdd().setPath(childFolder.getFullPath().toPortableString()).setURI(childRepository.getDirectory().toURI().toString()).call();
    TestRepository parentRepo = new TestRepository(parentRepository);
    parentRepo.trackAllFiles(parentProject);
    parentRepo.commit("Commit submodule");
    assertTrue(SubmoduleWalk.containsGitModulesFile(parentRepository));
    parentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
    assertTrue(childFolder.exists());
    // Let's get rid of the child project imported directly from the child
    // repository.
    childProject = ResourcesPlugin.getWorkspace().getRoot().getProject(CHILDPROJECT);
    childProject.delete(false, true, null);
    // Re-import it from the parent repo's submodule!
    IFile projectFile = childFolder.getFolder(CHILDPROJECT).getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
    assertTrue(projectFile.exists());
    ProjectRecord pr = new ProjectRecord(projectFile.getLocation().toFile());
    ProjectUtils.createProjects(Collections.singleton(pr), null, null);
    assertTrue(childProject.isOpen());
    // Now we have a parent repo in a state as if we had recursively
    // cloned some remote repo with a submodule and then imported all
    // projects. Look up the submodule repository instance through the
    // repository cache, so that we get the same instance that EGit
    // uses.
    subRepository = SubmoduleWalk.getSubmoduleRepository(childFolder.getParent().getLocation().toFile(), CHILD);
    assertNotNull(subRepository);
    subRepositoryGitDir = subRepository.getDirectory();
    subRepository.close();
    subRepository = lookupRepository(subRepositoryGitDir);
    assertNotNull(subRepository);
}
Also used : TestRepository(org.eclipse.egit.core.test.TestRepository) IFile(org.eclipse.core.resources.IFile) ProjectRecord(org.eclipse.egit.ui.internal.clone.ProjectRecord) IFolder(org.eclipse.core.resources.IFolder) Before(org.junit.Before)

Aggregations

TestRepository (org.eclipse.egit.core.test.TestRepository)45 Before (org.junit.Before)36 File (java.io.File)28 IFile (org.eclipse.core.resources.IFile)15 Git (org.eclipse.jgit.api.Git)6 TestProject (org.eclipse.egit.core.test.TestProject)5 Repository (org.eclipse.jgit.lib.Repository)5 Test (org.junit.Test)5 IProject (org.eclipse.core.resources.IProject)4 CloneOperation (org.eclipse.egit.core.op.CloneOperation)3 URIish (org.eclipse.jgit.transport.URIish)3 GitFlowRepository (org.eclipse.egit.gitflow.GitFlowRepository)2 RefUpdate (org.eclipse.jgit.lib.RefUpdate)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 IFolder (org.eclipse.core.resources.IFolder)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1