Search in sources :

Example 11 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class StagedChangeCacheTest method shouldListSingleWorkspaceAdditionInFolder.

@Test
public void shouldListSingleWorkspaceAdditionInFolder() throws Exception {
    // given
    writeTrashFile(db, "folder/a.txt", "trash");
    try (Git git = new Git(db)) {
        git.add().addFilepattern("folder/a.txt").call();
    }
    // when
    Map<String, Change> result = StagedChangeCache.build(db);
    // then
    assertThat(result.size(), is(1));
    assertFileAddition(result, "folder/a.txt", "a.txt");
}
Also used : Git(org.eclipse.jgit.api.Git) Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 12 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class StagedChangeCacheTest method shouldListSingleWorkspaceDeletionInFolder.

@Test
public void shouldListSingleWorkspaceDeletionInFolder() throws Exception {
    // given
    try (Git git = new Git(db)) {
        writeTrashFile(db, "folder/a.txt", "trash");
        git.add().addFilepattern("folder/a.txt").call();
        git.commit().setMessage("new commit").call();
        git.rm().addFilepattern("folder/a.txt").call();
    }
    // when
    Map<String, Change> result = StagedChangeCache.build(db);
    // then
    assertThat(result.size(), is(1));
    assertFileDeletion(result, "folder/a.txt", "a.txt");
}
Also used : Git(org.eclipse.jgit.api.Git) Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 13 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class StagedChangeCacheTest method shouldListTwoWorkspaceAdditionsInFolder.

@Test
public void shouldListTwoWorkspaceAdditionsInFolder() throws Exception {
    // given
    writeTrashFile(db, "folder/a.txt", "trash");
    writeTrashFile(db, "folder/b.txt", "trash");
    try (Git git = new Git(db)) {
        git.add().addFilepattern("folder/a.txt").addFilepattern("folder/b.txt").call();
    }
    // when
    Map<String, Change> result = StagedChangeCache.build(db);
    // then
    assertThat(result.size(), is(2));
    assertFileAddition(result, "folder/a.txt", "a.txt");
    assertFileAddition(result, "folder/b.txt", "b.txt");
}
Also used : Git(org.eclipse.jgit.api.Git) Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 14 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class StagedChangeCacheTest method shouldListTwoWorkspaceChanges.

@Test
public void shouldListTwoWorkspaceChanges() throws Exception {
    // given
    try (Git git = new Git(db)) {
        writeTrashFile(db, "a.txt", "trash");
        writeTrashFile(db, "b.txt", "trash");
        git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
        git.commit().setMessage("new commmit").call();
        writeTrashFile(db, "a.txt", "modification");
        writeTrashFile(db, "b.txt", "modification");
        git.add().addFilepattern("a.txt").addFilepattern("b.txt").call();
    }
    // when
    Map<String, Change> result = StagedChangeCache.build(db);
    // then
    assertThat(result.size(), is(2));
    assertFileChange(result, "a.txt", "a.txt");
    assertFileChange(result, "b.txt", "b.txt");
}
Also used : Git(org.eclipse.jgit.api.Git) Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Example 15 with Change

use of org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change in project egit by eclipse.

the class StagedChangeCacheTest method shouldListSingleWorkspaceDeletion.

@Test
public void shouldListSingleWorkspaceDeletion() throws Exception {
    // given
    try (Git git = new Git(db)) {
        writeTrashFile(db, "a.txt", "trash");
        git.add().addFilepattern("a.txt").call();
        git.commit().setMessage("initial add").call();
        git.rm().addFilepattern("a.txt").call();
    }
    // when
    Map<String, Change> result = StagedChangeCache.build(db);
    // then
    assertThat(result.size(), is(1));
    assertFileDeletion(result, "a.txt", "a.txt");
}
Also used : Git(org.eclipse.jgit.api.Git) Change(org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change) Test(org.junit.Test)

Aggregations

Change (org.eclipse.egit.core.synchronize.GitCommitsModelCache.Change)35 Test (org.junit.Test)29 Git (org.eclipse.jgit.api.Git)21 HashMap (java.util.HashMap)3 Repository (org.eclipse.jgit.lib.Repository)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 DirCacheIterator (org.eclipse.jgit.dircache.DirCacheIterator)2 MutableObjectId (org.eclipse.jgit.lib.MutableObjectId)2 TreeWalk (org.eclipse.jgit.treewalk.TreeWalk)2 Map (java.util.Map)1 Path (org.eclipse.core.runtime.Path)1 FileModelFactory (org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.FileModelFactory)1 TreeModelFactory (org.eclipse.egit.ui.internal.synchronize.model.TreeBuilder.TreeModelFactory)1 AbbreviatedObjectId (org.eclipse.jgit.lib.AbbreviatedObjectId)1 ObjectId (org.eclipse.jgit.lib.ObjectId)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1 RevWalk (org.eclipse.jgit.revwalk.RevWalk)1 EmptyTreeIterator (org.eclipse.jgit.treewalk.EmptyTreeIterator)1