@Test public void testComputeChangeScopeOfCliGitDiffOutput_TwoDiffsMultipleHunks() throws SourceControlException { mockStatic(GitDiffRunner.class); Diff diff1 = getChangeScopeResolverDiff(); Diff diff2 = getProcessorDiff(); when(GitDiffRunner.diff(any(), any())).thenReturn(Arrays.asList(diff1, diff2)); RevisionScope<ObjectId> scope = revisionResolver.resolve("fc776fe5e50", "e6f7c3d2954d6"); ChangeScope<Change> changeScope = changeScopeResolver.getChangeScope(scope); String fileName1 = "com/sandboni/core/scm/resolvers/ChangeScopeResolver.java"; String fileName2 = "com/sandboni/core/engine/Processor.java"; assertNotNull(changeScope); List<Change> changes1 = changeScope.getChanges(fileName1); assertNotNull(changes1); assertEquals(1, changes1.size()); List<Change> changes2 = changeScope.getChanges(fileName2); assertNotNull(changes2); assertEquals(3, changes2.size()); Change added = changes2.get(0); assertEquals(ChangeType.ADD, added.getType()); assertEquals(4, added.getLinesChanged().size()); Change deleted = changes2.get(1); assertEquals(ChangeType.DELETE, deleted.getType()); assertEquals(3, deleted.getLinesChanged().size()); Change modified = changes2.get(2); assertEquals(ChangeType.MODIFY, modified.getType()); assertEquals(2, modified.getLinesChanged().size()); }
@Override public ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope) throws SourceControlException { final ChangeScope<Change> scope = new ChangeScopeImpl(); List<Diff> diffs = GitDiffRunner.diff(repository, revisionScope); ObjectId toRevision = revisionScope.getTo(); diffs.forEach(throwingConsumerWrapper(d -> getChangesForDiff(d, scope, toRevision))); return scope; }
CliChangeScopeResolver extends JGitChangeScopeResolver implements ChangeScopeResolver { @Override public ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope) throws SourceControlException { final ChangeScope<Change> scope = new ChangeScopeImpl(); List<Diff> diffs = GitDiffRunner.diff(repository, revisionScope); ObjectId toRevision = revisionScope.getTo(); diffs.forEach(throwingConsumerWrapper(d -> getChangesForDiff(d, scope, toRevision))); return scope; } }
CliChangeScopeResolver extends JGitChangeScopeResolver implements ChangeScopeResolver { @Override public ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope) throws SourceControlException { final ChangeScope<Change> scope = new ChangeScopeImpl(); List<Diff> diffs = GitDiffRunner.diff(repository, revisionScope); ObjectId toRevision = revisionScope.getTo(); diffs.forEach(throwingConsumerWrapper(d -> getChangesForDiff(d, scope, toRevision))); return scope; } CliChangeScopeResolver(Repository repository, SourceControlFilter... filters); }
CliChangeScopeResolver extends JGitChangeScopeResolver implements ChangeScopeResolver { @Override public ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope) throws SourceControlException { final ChangeScope<Change> scope = new ChangeScopeImpl(); List<Diff> diffs = GitDiffRunner.diff(repository, revisionScope); ObjectId toRevision = revisionScope.getTo(); diffs.forEach(throwingConsumerWrapper(d -> getChangesForDiff(d, scope, toRevision))); return scope; } CliChangeScopeResolver(Repository repository, SourceControlFilter... filters); @Override ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope); }
CliChangeScopeResolver extends JGitChangeScopeResolver implements ChangeScopeResolver { @Override public ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope) throws SourceControlException { final ChangeScope<Change> scope = new ChangeScopeImpl(); List<Diff> diffs = GitDiffRunner.diff(repository, revisionScope); ObjectId toRevision = revisionScope.getTo(); diffs.forEach(throwingConsumerWrapper(d -> getChangesForDiff(d, scope, toRevision))); return scope; } CliChangeScopeResolver(Repository repository, SourceControlFilter... filters); @Override ChangeScope<Change> getChangeScope(RevisionScope<ObjectId> revisionScope);  }