Search in sources :

Example 36 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceAdapterTest method testDecorationIgnoredFile.

@Test
public void testDecorationIgnoredFile() throws Exception {
    // Create new file
    write(new File(project.getLocation().toFile(), "Test.dat"), "Something");
    write(new File(project.getLocation().toFile(), TEST_FILE2), "Something");
    write(new File(project.getLocation().toFile(), "Test"), "Something");
    // Test is prefix of TestFile
    write(new File(project.getLocation().toFile(), ".gitignore"), "Test");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    IResource file = project.findMember("Test.dat");
    IResource gitignore = project.findMember(".gitignore");
    IResource test = project.findMember("Test");
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { new TestDecoratableResource(project).tracked().dirty(), new TestDecoratableResource(gitignore), new TestDecoratableResource(file), new TestDecoratableResource(test).ignored() };
    waitForIndexDiffUpdate(true);
    IndexDiffData indexDiffData = indexDiffCacheEntry.getIndexDiff();
    IDecoratableResource[] actualDRs = { new DecoratableResourceAdapter(indexDiffData, project), new DecoratableResourceAdapter(indexDiffData, gitignore), new DecoratableResourceAdapter(indexDiffData, file), new DecoratableResourceAdapter(indexDiffData, test) };
    assertArrayEquals(expectedDRs, actualDRs);
}
Also used : File(java.io.File) IResource(org.eclipse.core.resources.IResource) IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Example 37 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceMappingTest method testAnyDirtyIsDirty.

@Test
public void testAnyDirtyIsDirty() throws Exception {
    gitAdd(git, rmContentA);
    gitAdd(git, rmContentB);
    gitCommit(git);
    write(rmContentA.getLocation().toFile(), "Changed content");
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked().dirty(), newExpectedDecoratableResource(rmContentB).tracked(), newExpectedDecoratableResourceMapping().tracked().dirty() };
    IndexDiffData indexDiffData = waitForIndexDiff(true);
    IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
    assertArrayEquals(expectedDRs, actualDRs);
    assertDecorationDirty(resourceMapping);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Example 38 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceMappingTest method testAnyTrackedIsTracked.

@Test
public void testAnyTrackedIsTracked() throws Exception {
    gitAdd(git, rmContentA);
    gitCommit(git);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked(), newExpectedDecoratableResource(rmContentB), newExpectedDecoratableResourceMapping().tracked() };
    IndexDiffData indexDiffData = waitForIndexDiff(true);
    IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
    assertArrayEquals(expectedDRs, actualDRs);
    assertDecorationTracked(resourceMapping);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Example 39 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceMappingTest method testMixedStagingStateIsModified_AddedNotStaged.

@Test
public void testMixedStagingStateIsModified_AddedNotStaged() throws Exception {
    gitAdd(git, rmContentA);
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked().added(), newExpectedDecoratableResource(rmContentB), newExpectedDecoratableResourceMapping().tracked().modified() };
    IndexDiffData indexDiffData = waitForIndexDiff(true);
    IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
    assertArrayEquals(expectedDRs, actualDRs);
    assertDecorationStaged(resourceMapping);
}
Also used : IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) Test(org.junit.Test)

Example 40 with IndexDiffData

use of org.eclipse.egit.core.internal.indexdiff.IndexDiffData in project egit by eclipse.

the class DecoratableResourceMappingTest method testAnyConflictsIsConflicts.

@Test
public void testAnyConflictsIsConflicts() throws Exception {
    // commit changes on master
    gitAdd(git, rmContentA);
    gitAdd(git, rmContentB);
    RevCommit masterCommit = gitCommit(git);
    // add change on new branch first_topic
    git.checkout().setCreateBranch(true).setName("first_topic").call();
    rmContentA = findFile(project, RM_CONTENT_A_FILE_NAME);
    write(rmContentA.getLocation().toFile(), "First Topic Content");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    gitAdd(git, rmContentA);
    RevCommit firstTopicCommit = gitCommit(git);
    // add change on new branch second_topic
    git.checkout().setCreateBranch(true).setStartPoint(masterCommit).setName("second_topic").call();
    rmContentA = findFile(project, RM_CONTENT_A_FILE_NAME);
    write(rmContentA.getLocation().toFile(), "Second Topic Content");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    gitAdd(git, rmContentA);
    gitCommit(git);
    // merge second_topic with first_topic
    MergeResult mergeResult = git.merge().include(firstTopicCommit).call();
    assertEquals(MergeStatus.CONFLICTING, mergeResult.getMergeStatus());
    IDecoratableResource[] expectedDRs = new IDecoratableResource[] { newExpectedDecoratableResource(rmContentA).tracked().conflicts(), newExpectedDecoratableResource(rmContentB).tracked(), newExpectedDecoratableResourceMapping().tracked().conflicts() };
    IndexDiffData indexDiffData = waitForIndexDiff(true);
    IDecoratableResource[] actualDRs = { newDecoratableResource(indexDiffData, rmContentA), newDecoratableResource(indexDiffData, rmContentB), newDecoratableResourceMapping(resourceMapping) };
    assertArrayEquals(expectedDRs, actualDRs);
    assertDecorationConflicts(resourceMapping);
}
Also used : MergeResult(org.eclipse.jgit.api.MergeResult) IndexDiffData(org.eclipse.egit.core.internal.indexdiff.IndexDiffData) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Aggregations

IndexDiffData (org.eclipse.egit.core.internal.indexdiff.IndexDiffData)47 Test (org.junit.Test)34 IResource (org.eclipse.core.resources.IResource)14 File (java.io.File)11 IFile (org.eclipse.core.resources.IFile)10 IndexDiffCacheEntry (org.eclipse.egit.core.internal.indexdiff.IndexDiffCacheEntry)9 RevCommit (org.eclipse.jgit.revwalk.RevCommit)6 IFolder (org.eclipse.core.resources.IFolder)4 MergeResult (org.eclipse.jgit.api.MergeResult)4 Repository (org.eclipse.jgit.lib.Repository)4 IOException (java.io.IOException)3 CoreException (org.eclipse.core.runtime.CoreException)3 IndexDiffCache (org.eclipse.egit.core.internal.indexdiff.IndexDiffCache)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IndexDiffChangedListener (org.eclipse.egit.core.internal.indexdiff.IndexDiffChangedListener)2