@Test public void testBlameNonExistingFile() throws SourceControlException { List<Integer> list = Arrays.asList(1, 2, 8, 9); String filepath = "engine/src/main/java/com/sandboni/core/engine/ApplicationAAAAAAAAAa.java"; Set<RevInfo> result = blameResolver.blame(filepath, list); assertNotNull(result); assertTrue(result.isEmpty()); }
public Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers) throws SourceControlException { try { String filepath = treeWalkResolver.getFullPath(packagePath); if (filepath == null) { LOGGER.warn("Unable to find package: {}", packagePath); return Collections.emptySet(); } Set<RevInfo> revInfoSet = new HashSet<>(); BlameResult blameResult = PorcelainApi.call(repository, git -> git.blame().setFilePath(filepath).setStartCommit(repository.resolve(revStr)).call()); if (blameResult == null) { LOGGER.warn("Blame result is empty for filepath: {}", filepath); return Collections.emptySet(); } int size = blameResult.getResultContents().size(); for (Integer i : lineNumbers) { if (i <= size) { RevCommit revision = blameResult.getSourceCommit(i - 1); RevInfo revInfo = getRevInfo(revision); revInfoSet.add(revInfo); } } LOGGER.debug("Blame result for package {} with lines {} is\n {}", packagePath, lineNumbers, revInfoSet); return revInfoSet; } catch (IOException e) { throw new SourceControlException(ErrorMessages.BLAME_EXCEPTION, e); } }
BlameResolver { public Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers) throws SourceControlException { try { String filepath = treeWalkResolver.getFullPath(packagePath); if (filepath == null) { LOGGER.warn("Unable to find package: {}", packagePath); return Collections.emptySet(); } Set<RevInfo> revInfoSet = new HashSet<>(); BlameResult blameResult = PorcelainApi.call(repository, git -> git.blame().setFilePath(filepath).setStartCommit(repository.resolve(revStr)).call()); if (blameResult == null) { LOGGER.warn("Blame result is empty for filepath: {}", filepath); return Collections.emptySet(); } int size = blameResult.getResultContents().size(); for (Integer i : lineNumbers) { if (i <= size) { RevCommit revision = blameResult.getSourceCommit(i - 1); RevInfo revInfo = getRevInfo(revision); revInfoSet.add(revInfo); } } LOGGER.debug("Blame result for package {} with lines {} is\n {}", packagePath, lineNumbers, revInfoSet); return revInfoSet; } catch (IOException e) { throw new SourceControlException(ErrorMessages.BLAME_EXCEPTION, e); } } }
BlameResolver { public Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers) throws SourceControlException { try { String filepath = treeWalkResolver.getFullPath(packagePath); if (filepath == null) { LOGGER.warn("Unable to find package: {}", packagePath); return Collections.emptySet(); } Set<RevInfo> revInfoSet = new HashSet<>(); BlameResult blameResult = PorcelainApi.call(repository, git -> git.blame().setFilePath(filepath).setStartCommit(repository.resolve(revStr)).call()); if (blameResult == null) { LOGGER.warn("Blame result is empty for filepath: {}", filepath); return Collections.emptySet(); } int size = blameResult.getResultContents().size(); for (Integer i : lineNumbers) { if (i <= size) { RevCommit revision = blameResult.getSourceCommit(i - 1); RevInfo revInfo = getRevInfo(revision); revInfoSet.add(revInfo); } } LOGGER.debug("Blame result for package {} with lines {} is\n {}", packagePath, lineNumbers, revInfoSet); return revInfoSet; } catch (IOException e) { throw new SourceControlException(ErrorMessages.BLAME_EXCEPTION, e); } } BlameResolver(Repository repository, String revStr); }
BlameResolver { public Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers) throws SourceControlException { try { String filepath = treeWalkResolver.getFullPath(packagePath); if (filepath == null) { LOGGER.warn("Unable to find package: {}", packagePath); return Collections.emptySet(); } Set<RevInfo> revInfoSet = new HashSet<>(); BlameResult blameResult = PorcelainApi.call(repository, git -> git.blame().setFilePath(filepath).setStartCommit(repository.resolve(revStr)).call()); if (blameResult == null) { LOGGER.warn("Blame result is empty for filepath: {}", filepath); return Collections.emptySet(); } int size = blameResult.getResultContents().size(); for (Integer i : lineNumbers) { if (i <= size) { RevCommit revision = blameResult.getSourceCommit(i - 1); RevInfo revInfo = getRevInfo(revision); revInfoSet.add(revInfo); } } LOGGER.debug("Blame result for package {} with lines {} is\n {}", packagePath, lineNumbers, revInfoSet); return revInfoSet; } catch (IOException e) { throw new SourceControlException(ErrorMessages.BLAME_EXCEPTION, e); } } BlameResolver(Repository repository, String revStr); Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers); }
BlameResolver { public Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers) throws SourceControlException { try { String filepath = treeWalkResolver.getFullPath(packagePath); if (filepath == null) { LOGGER.warn("Unable to find package: {}", packagePath); return Collections.emptySet(); } Set<RevInfo> revInfoSet = new HashSet<>(); BlameResult blameResult = PorcelainApi.call(repository, git -> git.blame().setFilePath(filepath).setStartCommit(repository.resolve(revStr)).call()); if (blameResult == null) { LOGGER.warn("Blame result is empty for filepath: {}", filepath); return Collections.emptySet(); } int size = blameResult.getResultContents().size(); for (Integer i : lineNumbers) { if (i <= size) { RevCommit revision = blameResult.getSourceCommit(i - 1); RevInfo revInfo = getRevInfo(revision); revInfoSet.add(revInfo); } } LOGGER.debug("Blame result for package {} with lines {} is\n {}", packagePath, lineNumbers, revInfoSet); return revInfoSet; } catch (IOException e) { throw new SourceControlException(ErrorMessages.BLAME_EXCEPTION, e); } } BlameResolver(Repository repository, String revStr); Set<RevInfo> blame(String packagePath, List<Integer> lineNumbers);  }