@Test public void parseALaLK() throws Exception { GitHistoryParser instance = new GitHistoryParser(false); String commitId1 = "1a23456789abcdef123456789abcderf123456789"; String commitId2 = "2a2323487092314kjsdafsad7829342kjhsdf3289"; String author1 = "username <username@example.com>"; String author2 = "username2 <username2@example.com>"; String committer = "committer <committer@example.com>"; String date1 = "2008-01-13T01:12:05-07:00"; String date2 = "2008-01-14T01:12:05-08:00"; String filename1 = "directory/filename.c"; String filename2 = "directory/filename.h"; String output = "commit " + commitId1 + "\n" + "Author: " + author1 + "\n" + "AuthorDate: " + date1 + "\n" + "Commit: " + committer + "\n" + "CommitDate: " + date2 + "\n" + "\n" + " Subject: subject title\n" + " \n" + " sdj fasodjfads jfa.kdsmf asdknf sadlfkm sad fma\n" + " dpojfv adsjv a,s.kdnvlø aok åpwaiorjf aldjfg ladijfg adkgf\n" + " jsdkgfj sadhkjfgs dlkjfg dksjgfh.\n" + " \n" + " djkhfgv ksadhg kdajhg ,dsn \n" + " x,nv ,xmcnvkadsjfnv,. zxmcnv edfhsgdksgf.\n" + " Dsdn ,dn ,dsng .,xcmnvefjhgiorfhgdskhg fdsg dfh sdf\n" + " skdjfas djskdjf ksadjhfn sa.,df .\n" + " \n" + " Zkjd flsdj flksadj fødsakjf asd jfsadijfosdhva.\n" + " \n" + " [user@example.com: something or another]\n" + " Signed-off-by: First Last <username@example.com>\n" + " Cc: Firstr Last <username@example.com>\n" + " Signed-off-by: First Last <username3@example.com>\n" + " Signed-off-by: Pinguin <pingu@example.com>\n" + "\n" + filename1 + "\n" + "\n" + "commit " + commitId2 + "\n" + "Author: " + author2 + "\n" + "AuthorDate: " + date1 + "\n" + "Commit: " + committer + "\n" + "CommitDate: " + date2 + "\n" + "\n" + " [PATCH] Subject heading.\n" + " \n" + " Some description of what is to come:\n" + " \n" + " * item 1\n" + " * item 2\n" + " * ...\n" + " * item n\n" + " \n" + " Signed-off-by: User <user@example.com>\n" + " Cc: \"First.Last\" <user2@example.com>\n" + " Signed-off-by: First Last <username3@example.com>\n" + " Signed-off-by: Pinguin <pingu@example.com>\n" + "\n" + filename1 + "\n" + filename2 + "\n"; History result = instance.parse(output); assertNotNull(result); assertEquals("Should contain two history entries", 2, 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(1, e0.getFiles().size()); assertEquals(File.separator + filename1.replace('/', File.separatorChar), e0.getFiles().first()); assertTrue(e0.getMessage().contains("subject title")); assertTrue(e0.getMessage().contains("Signed-off-by")); HistoryEntry e1 = result.getHistoryEntries().get(1); assertEquals(commitId2, e1.getRevision()); assertEquals(author2, e1.getAuthor()); assertEquals(new SimpleDateFormat(gitISODatePattern).parse(date1), e1.getDate()); assertEquals(2, e1.getFiles().size()); assertEquals(File.separator + filename1.replace('/', File.separatorChar), e1.getFiles().first()); assertEquals(File.separator + filename2.replace('/', File.separatorChar), e1.getFiles().last()); assertTrue(e1.getMessage().contains("[PATCH]")); assertTrue(e1.getMessage().contains("Signed-off-by")); }
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);  }