@Test public void testComputeChangeScopeFromGitDiffOutput_OneDiffOneHunk() throws SourceControlException { mockStatic(GitDiffRunner.class); Diff diff = getChangeScopeResolverDiff(); when(GitDiffRunner.diff(any(), any())).thenReturn(singletonList(diff)); RevisionScope<ObjectId> scope = revisionResolver.resolve("fc776fe5e50", "e6f7c3d2954d6"); ChangeScope<Change> changeScope = changeScopeResolver.getChangeScope(scope); String fileName = "com/sandboni/core/scm/resolvers/ChangeScopeResolver.java"; assertNotNull(changeScope); List<Change> changes = changeScope.getChanges(fileName); assertNotNull(changes); assertEquals(1, changes.size()); Change change = changes.get(0); assertEquals(fileName, change.getFilename()); assertEquals(ChangeType.DELETE, change.getType()); Set<Integer> linesChanged = change.getLinesChanged(); assertNotNull(linesChanged); assertEquals(2, linesChanged.size()); assertTrue(linesChanged.contains(10)); assertTrue(linesChanged.contains(11)); }
@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);  }