|
35 | 35 | import java.util.HashSet;
|
36 | 36 | import java.util.List;
|
37 | 37 | import java.util.Set;
|
| 38 | +import java.util.SortedSet; |
38 | 39 | import java.util.TreeSet;
|
39 | 40 |
|
40 | 41 | import org.eclipse.jgit.api.Git;
|
@@ -506,12 +507,59 @@ private void runRenamedTest(String fname, String cset, String content) throws Ex
|
506 | 507 | }
|
507 | 508 | }
|
508 | 509 |
|
| 510 | + @Test |
| 511 | + public void testHistory() throws Exception { |
| 512 | + RuntimeEnvironment.getInstance().setHandleHistoryOfRenamedFiles(false); |
| 513 | + File root = new File(repository.getSourceRoot(), "git"); |
| 514 | + GitRepository gitrepo = (GitRepository) RepositoryFactory.getRepository(root); |
| 515 | + |
| 516 | + History history = gitrepo.getHistory(root); |
| 517 | + assertNotNull(history); |
| 518 | + assertNotNull(history.getHistoryEntries()); |
| 519 | + assertEquals(8, history.getHistoryEntries().size()); |
| 520 | + assertEquals(0, history.getRenamedFiles().size()); |
| 521 | + |
| 522 | + History expectedHistory = new History(List.of( |
| 523 | + new HistoryEntry("84599b3c", new Date(1485438707000L), |
| 524 | + "Kryštof Tulinger <[email protected]>", null, |
| 525 | + " renaming directories\n\n", true, |
| 526 | + Set.of("/git/moved2/renamed2.c")), |
| 527 | + new HistoryEntry("67dfbe26", new Date(1485263397000L), |
| 528 | + "Kryštof Tulinger <[email protected]>", null, |
| 529 | + " renaming renamed -> renamed2\n\n", true, |
| 530 | + Set.of("/git/moved/renamed2.c")), |
| 531 | + new HistoryEntry("1086eaf5", new Date(1485263368000L), |
| 532 | + "Kryštof Tulinger <[email protected]>", null, |
| 533 | + " adding some lines into renamed.c\n\n", true, |
| 534 | + Set.of("/git/moved/renamed.c")), |
| 535 | + new HistoryEntry("b6413947", new Date(1485263264000L), |
| 536 | + "Kryštof Tulinger <[email protected]>", null, |
| 537 | + " moved renamed.c to new location\n\n", true, |
| 538 | + Set.of("/git/moved/renamed.c")), |
| 539 | + new HistoryEntry("ce4c98ec", new Date(1485263232000L), |
| 540 | + "Kryštof Tulinger <[email protected]>", null, |
| 541 | + " adding simple file for renamed file testing\n\n", true, |
| 542 | + Set.of("/git/renamed.c")), |
| 543 | + new HistoryEntry("aa35c258", new Date(1218571965000L), |
| 544 | + "Trond Norbye <[email protected]>", null, |
| 545 | + " Add lint make target and fix lint warnings\n\n", true, |
| 546 | + Set.of("/git/Makefile", "/git/main.c")), |
| 547 | + new HistoryEntry("84821564", new Date(1218571643000L), |
| 548 | + "Trond Norbye <[email protected]>", null, |
| 549 | + " Add the result of a make on Solaris x86\n\n", true, |
| 550 | + Set.of("/git/main.o", "/git/testsprog")), |
| 551 | + new HistoryEntry("bb74b7e8", new Date(1218571573000L), |
| 552 | + "Trond Norbye <[email protected]>", null, |
| 553 | + " Added a small test program\n\n", true, |
| 554 | + Set.of("/git/Makefile", "/git/header.h", "/git/main.c")))); |
| 555 | + assertEquals(expectedHistory, history); |
| 556 | + } |
| 557 | + |
509 | 558 | @Test
|
510 | 559 | public void testRenamedHistory() throws Exception {
|
511 | 560 | RuntimeEnvironment.getInstance().setHandleHistoryOfRenamedFiles(true);
|
512 | 561 | File root = new File(repository.getSourceRoot(), "git");
|
513 |
| - GitRepository gitrepo |
514 |
| - = (GitRepository) RepositoryFactory.getRepository(root); |
| 562 | + GitRepository gitrepo = (GitRepository) RepositoryFactory.getRepository(root); |
515 | 563 |
|
516 | 564 | History history = gitrepo.getHistory(root);
|
517 | 565 | assertNotNull(history);
|
|
0 commit comments