@Test public void testDateFormats() { GitHistoryParser instance = new GitHistoryParser(false); String[][] dates = new String[][]{ new String[]{"2017-07-25T13:17:44+02:00", gitISODatePattern}, }; for (int i = 0; i < dates.length; i++) { try { String commitId = "1a23456789abcdef123456789abcderf123456789"; String author = "username <username@asfdsaf-23412-sadf-cxvdsfg3123-sfasdf>"; String date = dates[i][0]; String format = dates[i][1]; Date parsedDate = new SimpleDateFormat(format).parse(date); String output = "commit " + commitId + "\n" + "Author: " + author + "\n" + "AuthorDate: " + date + "\n" + "Commit: " + author + "\n" + "CommitDate: " + date + "\n" + "\n" + " patch from somebody <user.name@example.com>:\n" + " \n" + " commit message.\n" + " \n" + " \n" + " git-svn-id: http: History result = instance.parse(output); assertNotNull(result); assertEquals("Should contain one history entry", 1, result.getHistoryEntries().size()); HistoryEntry e0 = result.getHistoryEntries().get(0); assertEquals(commitId, e0.getRevision()); assertEquals(author, e0.getAuthor()); assertEquals("The date " + parsedDate + " should be equal to the parsed date " + e0.getDate(), parsedDate, e0.getDate()); assertEquals(0, e0.getFiles().size()); } catch (ParseException ex) { fail("Should not throw a parse exception" + ex); } catch (IOException ex) { fail("Should not throw an IO exception" + ex); } } }
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);  }