@Test public void parseALaMemcached() throws Exception { GitHistoryParser instance = new GitHistoryParser(false); String commitId1 = "1a23456789abcdef123456789abcderf123456789"; String commitId2 = "2a2323487092314kjsdafsad7829342kjhsdf3289"; String commitId3 = "3asdfq234242871934g2sadfsa327894234sa2389"; String author1 = "username <username@asfdsaf-23412-sadf-cxvdsfg3123-sfasdf>"; String author2 = "username2 <username2@as345af-23412-sadf-cxvdsfg3123-sfasdf>"; String date1 = "2008-04-01T15:12:51+00:00"; String date2 = "2006-05-22T15:23:15+00:00"; String output = "commit " + commitId1 + "\n" + "Author: " + author1 + "\n" + "AuthorDate: " + date1 + "\n" + "Commit: " + author1 + "\n" + "CommitDate: " + date1 + "\n" + "\n" + " patch from somebody <user.name@example.com>:\n" + " \n" + " commit message.\n" + " \n" + " \n" + " git-svn-id: http: "\n" + "commit " + commitId2 + "\n" + "Author: " + author2 + "\n" + "AuthorDate: " + date2 + "\n" + "Commit: " + author2 + "\n" + "CommitDate: " + date2 + "\n" + "\n" + " r123@branch: username | some date\n" + " some comment\n" + " \n" + " \n" + " git-svn-id: http: "\n" + "commit " + commitId3 + "\n" + "Author: " + author1 + "\n" + "AuthorDate: " + date1 + "\n" + "Commit: " + author2 + "\n" + "CommitDate: " + date2 + "\n" + "\n" + " some comment\n" + " \n" + " git-svn-id: http: History result = instance.parse(output); assertNotNull(result); assertEquals("Should contain three history entries", 3, result.getHistoryEntries().size()); HistoryEntry e0 = result.getHistoryEntries().get(0); assertEquals(commitId1, e0.getRevision()); assertEquals(author1, e0.getAuthor()); assertEquals(new SimpleDateFormat(gitISODatePattern).parse(date1), e0.getDate()); assertEquals(0, e0.getFiles().size()); HistoryEntry e1 = result.getHistoryEntries().get(1); assertEquals(commitId2, e1.getRevision()); assertEquals(author2, e1.getAuthor()); assertEquals(new SimpleDateFormat(gitISODatePattern).parse(date2), e1.getDate()); assertEquals(0, e1.getFiles().size()); HistoryEntry e2 = result.getHistoryEntries().get(2); assertEquals(commitId3, e2.getRevision()); assertEquals(author1, e2.getAuthor()); assertEquals(new SimpleDateFormat(gitISODatePattern).parse(date1), e2.getDate()); assertEquals(0, e2.getFiles().size()); }
History parse(File file, Repository repos, String sinceRevision) throws HistoryException { myDir = repos.getDirectoryName() + File.separator; repository = (GitRepository) repos; RenamedFilesParser parser = new RenamedFilesParser(); try { Executor executor = repository.getHistoryLogExecutor(file, sinceRevision); int status = executor.exec(true, this); if (status != 0) { throw new HistoryException( String.format("Failed to get history for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } if (handleRenamedFiles) { executor = repository.getRenamedFilesExecutor(file, sinceRevision); status = executor.exec(true, parser); if (status != 0) { throw new HistoryException( String.format("Failed to get renamed files for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } } } catch (IOException e) { throw new HistoryException( String.format("Failed to get history for: \"%s\"", file.getAbsolutePath()), e); } return new History(entries, parser.getRenamedFiles()); }
GitHistoryParser implements Executor.StreamHandler { History parse(File file, Repository repos, String sinceRevision) throws HistoryException { myDir = repos.getDirectoryName() + File.separator; repository = (GitRepository) repos; RenamedFilesParser parser = new RenamedFilesParser(); try { Executor executor = repository.getHistoryLogExecutor(file, sinceRevision); int status = executor.exec(true, this); if (status != 0) { throw new HistoryException( String.format("Failed to get history for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } if (handleRenamedFiles) { executor = repository.getRenamedFilesExecutor(file, sinceRevision); status = executor.exec(true, parser); if (status != 0) { throw new HistoryException( String.format("Failed to get renamed files for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } } } catch (IOException e) { throw new HistoryException( String.format("Failed to get history for: \"%s\"", file.getAbsolutePath()), e); } return new History(entries, parser.getRenamedFiles()); } }
GitHistoryParser implements Executor.StreamHandler { History parse(File file, Repository repos, String sinceRevision) throws HistoryException { myDir = repos.getDirectoryName() + File.separator; repository = (GitRepository) repos; RenamedFilesParser parser = new RenamedFilesParser(); try { Executor executor = repository.getHistoryLogExecutor(file, sinceRevision); int status = executor.exec(true, this); if (status != 0) { throw new HistoryException( String.format("Failed to get history for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } if (handleRenamedFiles) { executor = repository.getRenamedFilesExecutor(file, sinceRevision); status = executor.exec(true, parser); if (status != 0) { throw new HistoryException( String.format("Failed to get renamed files for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } } } catch (IOException e) { throw new HistoryException( String.format("Failed to get history for: \"%s\"", file.getAbsolutePath()), e); } return new History(entries, parser.getRenamedFiles()); } GitHistoryParser(boolean flag); }
GitHistoryParser implements Executor.StreamHandler { History parse(File file, Repository repos, String sinceRevision) throws HistoryException { myDir = repos.getDirectoryName() + File.separator; repository = (GitRepository) repos; RenamedFilesParser parser = new RenamedFilesParser(); try { Executor executor = repository.getHistoryLogExecutor(file, sinceRevision); int status = executor.exec(true, this); if (status != 0) { throw new HistoryException( String.format("Failed to get history for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } if (handleRenamedFiles) { executor = repository.getRenamedFilesExecutor(file, sinceRevision); status = executor.exec(true, parser); if (status != 0) { throw new HistoryException( String.format("Failed to get renamed files for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } } } catch (IOException e) { throw new HistoryException( String.format("Failed to get history for: \"%s\"", file.getAbsolutePath()), e); } return new History(entries, parser.getRenamedFiles()); } GitHistoryParser(boolean flag); History getHistory(); @Override void processStream(InputStream input); }
GitHistoryParser implements Executor.StreamHandler { History parse(File file, Repository repos, String sinceRevision) throws HistoryException { myDir = repos.getDirectoryName() + File.separator; repository = (GitRepository) repos; RenamedFilesParser parser = new RenamedFilesParser(); try { Executor executor = repository.getHistoryLogExecutor(file, sinceRevision); int status = executor.exec(true, this); if (status != 0) { throw new HistoryException( String.format("Failed to get history for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } if (handleRenamedFiles) { executor = repository.getRenamedFilesExecutor(file, sinceRevision); status = executor.exec(true, parser); if (status != 0) { throw new HistoryException( String.format("Failed to get renamed files for: \"%s\" Exit code: %d", file.getAbsolutePath(), status)); } } } catch (IOException e) { throw new HistoryException( String.format("Failed to get history for: \"%s\"", file.getAbsolutePath()), e); } return new History(entries, parser.getRenamedFiles()); } GitHistoryParser(boolean flag); History getHistory(); @Override void processStream(InputStream input);  }