@Test public void computeChangedPaths_should_not_crash_when_getRepositoryRootURL_getPath_is_empty() throws SVNException { assertThat(SVNURL.parseURIEncoded("http: assertThat(SVNURL.parseURIEncoded("http: SVNClientManager svnClientManagerMock = mock(SVNClientManager.class); SVNWCClient svnwcClientMock = mock(SVNWCClient.class); when(svnClientManagerMock.getWCClient()).thenReturn(svnwcClientMock); SVNLogClient svnLogClient = mock(SVNLogClient.class); when(svnClientManagerMock.getLogClient()).thenReturn(svnLogClient); SVNInfo svnInfoMock = mock(SVNInfo.class); when(svnwcClientMock.doInfo(any(), any())).thenReturn(svnInfoMock); when(svnInfoMock.getRepositoryRootURL()).thenReturn(SVNURL.parseURIEncoded("http: when(svnInfoMock.getURL()).thenReturn(SVNURL.parseURIEncoded("http: assertThat(SvnScmProvider.computeChangedPaths(Paths.get("/"), svnClientManagerMock)).isEmpty(); }
static Set<Path> computeChangedPaths(Path projectBasedir, SVNClientManager clientManager) throws SVNException { SVNWCClient wcClient = clientManager.getWCClient(); SVNInfo svnInfo = wcClient.doInfo(projectBasedir.toFile(), null); Path svnRootPath = toPath(svnInfo.getRepositoryRootURL()); if (svnRootPath.equals(Paths.get(""))) { svnRootPath = Paths.get("/"); } Path svnProjectPath = toPath(svnInfo.getURL()); Path inRepoProjectPath = Paths.get("/").resolve(svnRootPath.relativize(svnProjectPath)); Set<Path> paths = new HashSet<>(); Set<Path> removed = new HashSet<>(); SVNLogClient svnLogClient = clientManager.getLogClient(); svnLogClient.doLog(new File[] {projectBasedir.toFile()}, null, null, null, true, true, 0, svnLogEntry -> { svnLogEntry.getChangedPaths().values().forEach(entry -> { if (entry.getKind().equals(SVNNodeKind.FILE)) { Path path = projectBasedir.resolve(inRepoProjectPath.relativize(Paths.get(entry.getPath()))); if (isModified(entry)) { if (!removed.contains(path)) { paths.add(path); } } else if (entry.getType() == SVNLogEntryPath.TYPE_DELETED) { removed.add(path); } } }); }); return paths; }
SvnScmProvider extends ScmProvider { static Set<Path> computeChangedPaths(Path projectBasedir, SVNClientManager clientManager) throws SVNException { SVNWCClient wcClient = clientManager.getWCClient(); SVNInfo svnInfo = wcClient.doInfo(projectBasedir.toFile(), null); Path svnRootPath = toPath(svnInfo.getRepositoryRootURL()); if (svnRootPath.equals(Paths.get(""))) { svnRootPath = Paths.get("/"); } Path svnProjectPath = toPath(svnInfo.getURL()); Path inRepoProjectPath = Paths.get("/").resolve(svnRootPath.relativize(svnProjectPath)); Set<Path> paths = new HashSet<>(); Set<Path> removed = new HashSet<>(); SVNLogClient svnLogClient = clientManager.getLogClient(); svnLogClient.doLog(new File[] {projectBasedir.toFile()}, null, null, null, true, true, 0, svnLogEntry -> { svnLogEntry.getChangedPaths().values().forEach(entry -> { if (entry.getKind().equals(SVNNodeKind.FILE)) { Path path = projectBasedir.resolve(inRepoProjectPath.relativize(Paths.get(entry.getPath()))); if (isModified(entry)) { if (!removed.contains(path)) { paths.add(path); } } else if (entry.getType() == SVNLogEntryPath.TYPE_DELETED) { removed.add(path); } } }); }); return paths; } }
SvnScmProvider extends ScmProvider { static Set<Path> computeChangedPaths(Path projectBasedir, SVNClientManager clientManager) throws SVNException { SVNWCClient wcClient = clientManager.getWCClient(); SVNInfo svnInfo = wcClient.doInfo(projectBasedir.toFile(), null); Path svnRootPath = toPath(svnInfo.getRepositoryRootURL()); if (svnRootPath.equals(Paths.get(""))) { svnRootPath = Paths.get("/"); } Path svnProjectPath = toPath(svnInfo.getURL()); Path inRepoProjectPath = Paths.get("/").resolve(svnRootPath.relativize(svnProjectPath)); Set<Path> paths = new HashSet<>(); Set<Path> removed = new HashSet<>(); SVNLogClient svnLogClient = clientManager.getLogClient(); svnLogClient.doLog(new File[] {projectBasedir.toFile()}, null, null, null, true, true, 0, svnLogEntry -> { svnLogEntry.getChangedPaths().values().forEach(entry -> { if (entry.getKind().equals(SVNNodeKind.FILE)) { Path path = projectBasedir.resolve(inRepoProjectPath.relativize(Paths.get(entry.getPath()))); if (isModified(entry)) { if (!removed.contains(path)) { paths.add(path); } } else if (entry.getType() == SVNLogEntryPath.TYPE_DELETED) { removed.add(path); } } }); }); return paths; } SvnScmProvider(SvnConfiguration configuration, SvnBlameCommand blameCommand, FindFork findFork); }
SvnScmProvider extends ScmProvider { static Set<Path> computeChangedPaths(Path projectBasedir, SVNClientManager clientManager) throws SVNException { SVNWCClient wcClient = clientManager.getWCClient(); SVNInfo svnInfo = wcClient.doInfo(projectBasedir.toFile(), null); Path svnRootPath = toPath(svnInfo.getRepositoryRootURL()); if (svnRootPath.equals(Paths.get(""))) { svnRootPath = Paths.get("/"); } Path svnProjectPath = toPath(svnInfo.getURL()); Path inRepoProjectPath = Paths.get("/").resolve(svnRootPath.relativize(svnProjectPath)); Set<Path> paths = new HashSet<>(); Set<Path> removed = new HashSet<>(); SVNLogClient svnLogClient = clientManager.getLogClient(); svnLogClient.doLog(new File[] {projectBasedir.toFile()}, null, null, null, true, true, 0, svnLogEntry -> { svnLogEntry.getChangedPaths().values().forEach(entry -> { if (entry.getKind().equals(SVNNodeKind.FILE)) { Path path = projectBasedir.resolve(inRepoProjectPath.relativize(Paths.get(entry.getPath()))); if (isModified(entry)) { if (!removed.contains(path)) { paths.add(path); } } else if (entry.getType() == SVNLogEntryPath.TYPE_DELETED) { removed.add(path); } } }); }); return paths; } SvnScmProvider(SvnConfiguration configuration, SvnBlameCommand blameCommand, FindFork findFork); @Override String key(); @Override boolean supports(File baseDir); @Override BlameCommand blameCommand(); @CheckForNull @Override Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir); @CheckForNull @Override Map<Path, Set<Integer>> branchChangedLines(String targetBranchName, Path rootBaseDir, Set<Path> changedFiles); @CheckForNull Instant forkDate(Path rootBaseDir, String referenceBranch); }
SvnScmProvider extends ScmProvider { static Set<Path> computeChangedPaths(Path projectBasedir, SVNClientManager clientManager) throws SVNException { SVNWCClient wcClient = clientManager.getWCClient(); SVNInfo svnInfo = wcClient.doInfo(projectBasedir.toFile(), null); Path svnRootPath = toPath(svnInfo.getRepositoryRootURL()); if (svnRootPath.equals(Paths.get(""))) { svnRootPath = Paths.get("/"); } Path svnProjectPath = toPath(svnInfo.getURL()); Path inRepoProjectPath = Paths.get("/").resolve(svnRootPath.relativize(svnProjectPath)); Set<Path> paths = new HashSet<>(); Set<Path> removed = new HashSet<>(); SVNLogClient svnLogClient = clientManager.getLogClient(); svnLogClient.doLog(new File[] {projectBasedir.toFile()}, null, null, null, true, true, 0, svnLogEntry -> { svnLogEntry.getChangedPaths().values().forEach(entry -> { if (entry.getKind().equals(SVNNodeKind.FILE)) { Path path = projectBasedir.resolve(inRepoProjectPath.relativize(Paths.get(entry.getPath()))); if (isModified(entry)) { if (!removed.contains(path)) { paths.add(path); } } else if (entry.getType() == SVNLogEntryPath.TYPE_DELETED) { removed.add(path); } } }); }); return paths; } SvnScmProvider(SvnConfiguration configuration, SvnBlameCommand blameCommand, FindFork findFork); @Override String key(); @Override boolean supports(File baseDir); @Override BlameCommand blameCommand(); @CheckForNull @Override Set<Path> branchChangedFiles(String targetBranchName, Path rootBaseDir); @CheckForNull @Override Map<Path, Set<Integer>> branchChangedLines(String targetBranchName, Path rootBaseDir, Set<Path> changedFiles); @CheckForNull Instant forkDate(Path rootBaseDir, String referenceBranch);  }