Skip to content

Commit bf072ca

Browse files
author
Vladimir Kotal
committed
test history with start commit
1 parent 98364b7 commit bf072ca

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ public boolean equals(Object o) {
224224
return false;
225225
}
226226
HistoryEntry that = (HistoryEntry) o;
227+
// TODO: more robust w.r.t. null
227228
return this.getAuthor().equals(that.getAuthor()) &&
228229
this.getRevision().equals(that.getRevision()) &&
229230
this.getDate().equals(that.getDate()) &&

opengrok-indexer/src/test/java/org/opengrok/indexer/history/GitRepositoryTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,10 @@ public void testHistory() throws Exception {
519519
assertEquals(8, history.getHistoryEntries().size());
520520
assertEquals(0, history.getRenamedFiles().size());
521521

522-
History expectedHistory = new History(List.of(
522+
List<HistoryEntry> entries = List.of(
523523
new HistoryEntry("84599b3c", new Date(1485438707000L),
524524
"Kryštof Tulinger <[email protected]>", null,
525-
" renaming directories\n\n", true,
525+
" renaming directories\n\n", true,
526526
Set.of("/git/moved2/renamed2.c")),
527527
new HistoryEntry("67dfbe26", new Date(1485263397000L),
528528
"Kryštof Tulinger <[email protected]>", null,
@@ -536,7 +536,7 @@ public void testHistory() throws Exception {
536536
"Kryštof Tulinger <[email protected]>", null,
537537
" moved renamed.c to new location\n\n", true,
538538
Set.of("/git/moved/renamed.c")),
539-
new HistoryEntry("ce4c98ec", new Date(1485263232000L),
539+
new HistoryEntry("ce4c98ec", new Date(1485263232000L), // start in the sub-test below
540540
"Kryštof Tulinger <[email protected]>", null,
541541
" adding simple file for renamed file testing\n\n", true,
542542
Set.of("/git/renamed.c")),
@@ -551,7 +551,17 @@ public void testHistory() throws Exception {
551551
new HistoryEntry("bb74b7e8", new Date(1218571573000L),
552552
"Trond Norbye <[email protected]>", null,
553553
" Added a small test program\n\n", true,
554-
Set.of("/git/Makefile", "/git/header.h", "/git/main.c"))));
554+
Set.of("/git/Makefile", "/git/header.h", "/git/main.c")));
555+
History expectedHistory = new History(entries);
556+
assertEquals(expectedHistory, history);
557+
558+
// Retry with start changeset.
559+
history = gitrepo.getHistory(root, "ce4c98ec");
560+
assertNotNull(history);
561+
assertNotNull(history.getHistoryEntries());
562+
assertEquals(4, history.getHistoryEntries().size());
563+
assertEquals(0, history.getRenamedFiles().size());
564+
expectedHistory = new History(entries.subList(0, 4));
555565
assertEquals(expectedHistory, history);
556566
}
557567

0 commit comments

Comments
 (0)