Search in sources :

Example 26 with TestProject

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

the class CreatePatchOperationTest method testComputeWorkspacePathRepoAboveProject.

@Test
public void testComputeWorkspacePathRepoAboveProject() throws Exception {
    testRepository.disconnect(project.getProject());
    // new setup
    project = new TestProject(true, "repo/bundles/Project-1", true, null);
    File repo = new File(project.getProject().getLocationURI().getPath()).getParentFile().getParentFile();
    gitDir = new File(repo, Constants.DOT_GIT);
    testRepository = new TestRepository(gitDir);
    testRepository.connect(project.getProject());
    IPath oldPath = CreatePatchOperation.computeWorkspacePath(new Path("bundles/Project-1/test-file"), project.getProject());
    IPath newPath = CreatePatchOperation.computeWorkspacePath(new Path("bundles/Project-1/test-file"), project.getProject());
    assertPatch("test-file", oldPath.toString());
    assertPatch("test-file", newPath.toString());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) TestRepository(org.eclipse.egit.core.test.TestRepository) TestProject(org.eclipse.egit.core.test.TestProject) IPath(org.eclipse.core.runtime.IPath) File(java.io.File) Test(org.junit.Test)

Example 27 with TestProject

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

the class IgnoreOperationTest method testWithNestedProjects.

@Test
public void testWithNestedProjects() throws Exception {
    TestProject nested = new TestProject(true, "Project-1/Project-2");
    try {
        // Use Project-1 to create folder, Project-2 to get file to try to
        // confuse any caches in workspace root (location -> IResource).
        project.createFolder("Project-2/please");
        IFile ignoreme = nested.createFile("please/ignoreme", new byte[0]);
        IgnoreOperation operation = executeIgnore(ignoreme.getLocation());
        String content = nested.getFileContent("please/.gitignore");
        assertEquals("/ignoreme\n", content);
        assertFalse(operation.isGitignoreOutsideWSChanged());
    } finally {
        nested.dispose();
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) TestProject(org.eclipse.egit.core.test.TestProject) IgnoreOperation(org.eclipse.egit.core.op.IgnoreOperation) Test(org.junit.Test)

Aggregations

TestProject (org.eclipse.egit.core.test.TestProject)27 IFile (org.eclipse.core.resources.IFile)17 Test (org.junit.Test)17 TestRepository (org.eclipse.egit.core.test.TestRepository)11 DirCache (org.eclipse.jgit.dircache.DirCache)11 File (java.io.File)9 AddToIndexOperation (org.eclipse.egit.core.op.AddToIndexOperation)9 IProject (org.eclipse.core.resources.IProject)8 IPath (org.eclipse.core.runtime.IPath)8 Repository (org.eclipse.jgit.lib.Repository)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Theory (org.junit.experimental.theories.Theory)5 IProjectDescription (org.eclipse.core.resources.IProjectDescription)4 Path (org.eclipse.core.runtime.Path)4 ConnectProviderOperation (org.eclipse.egit.core.op.ConnectProviderOperation)3 ObjectId (org.eclipse.jgit.lib.ObjectId)3 Ignore (org.junit.Ignore)3 ArrayList (java.util.ArrayList)2 TreeSet (java.util.TreeSet)2 IResource (org.eclipse.core.resources.IResource)2