use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorter method compare.
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof GitModelBlob && !(e2 instanceof GitModelBlob))
return 1;
if (e2 instanceof GitModelBlob && !(e1 instanceof GitModelBlob))
return -1;
if (e1 instanceof GitModelWorkingTree)
return -1;
if (e2 instanceof GitModelWorkingTree)
return 1;
if (e1 instanceof GitModelCache)
return -2;
if (e2 instanceof GitModelCache)
return 2;
if ((e1 instanceof GitModelTree && e2 instanceof GitModelTree) || (e1 instanceof GitModelBlob && e2 instanceof GitModelBlob))
return super.compare(viewer, e1, e2);
if (e1 instanceof GitModelTree && e2 instanceof GitModelCommit)
return 1;
if (e1 instanceof GitModelCommit && e2 instanceof GitModelCommit) {
Commit rc1 = ((GitModelCommit) e1).getCachedCommitObj();
Commit rc2 = ((GitModelCommit) e2).getCachedCommitObj();
return rc2.getCommitDate().compareTo(rc1.getCommitDate());
}
return super.compare(viewer, e1, e2);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method workingTreeShouldBeLessThanBlob.
@Test
public void workingTreeShouldBeLessThanBlob() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelBlob blob = mock(GitModelBlob.class);
GitModelWorkingTree workingTree = mock(GitModelWorkingTree.class);
// when
int actual = sorter.compare(viewer, workingTree, blob);
// then
assertTrue(actual < 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method commitTreeShouldBeLessThanBlob.
@Test
public void commitTreeShouldBeLessThanBlob() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelCommit commit = mock(GitModelCommit.class);
GitModelBlob blob = mock(GitModelBlob.class);
// when
int actual = sorter.compare(viewer, commit, blob);
// then
assertTrue(actual < 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method blobShouldBeGreaterThanTree.
@Test
public void blobShouldBeGreaterThanTree() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelBlob blob = mock(GitModelBlob.class);
GitModelTree tree = mock(GitModelTree.class);
// when
int actual = sorter.compare(viewer, blob, tree);
// then
assertTrue(actual > 0);
}
use of org.eclipse.egit.ui.internal.synchronize.model.GitModelBlob in project egit by eclipse.
the class GitChangeSetSorterTest method commitTreeShouldBeLessThanTree.
@Test
public void commitTreeShouldBeLessThanTree() {
// given
Viewer viewer = mock(Viewer.class);
GitChangeSetSorter sorter = new GitChangeSetSorter();
GitModelTree tree = mock(GitModelTree.class);
GitModelBlob blob = mock(GitModelBlob.class);
// when
int actual = sorter.compare(viewer, tree, blob);
// then
assertTrue(actual < 0);
}
Aggregations