Skip to content

Commit 2273c85

Browse files
committed
getCommitMessages() -> log()
1 parent 74a7def commit 2273c85

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

src/main/java/org/scm4j/vcs/svn/SVNVCS.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -458,17 +458,18 @@ public int compare(SVNDirEntry o1, SVNDirEntry o2) {
458458
}
459459
}
460460
}
461-
461+
462462
@Override
463-
public List<String> getCommitMessages(String branchName, Integer limit) {
464-
final List<String> res = new ArrayList<>();
463+
public List<VCSCommit> log(String branchName, int limit) {
464+
final List<VCSCommit> res = new ArrayList<>();
465465
try {
466+
getBranchUrl(branchName); // for exception test only
466467
repository.log(new String[] { getBranchName(branchName) },
467468
-1L /* start from head descending */,
468469
0L, true, true, limit, new ISVNLogEntryHandler() {
469470
@Override
470471
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
471-
res.add(logEntry.getMessage());
472+
res.add(svnLogEntryToVCSCommit(logEntry));
472473
}
473474
});
474475
return res;
@@ -518,8 +519,7 @@ public List<VCSCommit> getCommitsRange(String branchName, String firstCommitId,
518519
new ISVNLogEntryHandler() {
519520
@Override
520521
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
521-
VCSCommit commit = new VCSCommit(Long.toString(logEntry.getRevision()), logEntry.getMessage(),
522-
logEntry.getAuthor());
522+
VCSCommit commit = svnLogEntryToVCSCommit(logEntry);
523523
res.add(commit);
524524
}
525525
});
@@ -530,6 +530,11 @@ public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
530530
throw new RuntimeException(e);
531531
}
532532
}
533+
534+
private VCSCommit svnLogEntryToVCSCommit(SVNLogEntry logEntry) {
535+
return new VCSCommit(Long.toString(logEntry.getRevision()), logEntry.getMessage(),
536+
logEntry.getAuthor());
537+
}
533538

534539
@Override
535540
public List<VCSCommit> getCommitsRange(String branchName, String firstCommitId, String untilCommitId) {
@@ -543,9 +548,7 @@ public List<VCSCommit> getCommitsRange(String branchName, String firstCommitId,
543548
new ISVNLogEntryHandler() {
544549
@Override
545550
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
546-
VCSCommit commit = new VCSCommit(Long.toString(logEntry.getRevision()), logEntry.getMessage(),
547-
logEntry.getAuthor());
548-
res.add(commit);
551+
res.add(svnLogEntryToVCSCommit(logEntry));
549552
}
550553
});
551554
return res;
@@ -566,8 +569,7 @@ public VCSCommit getHeadCommit(String branchName) {
566569
try {
567570
SVNLogEntry entry = revToSVNEntry(getBranchName(branchName), -1L);
568571
if (entry != null) {
569-
return new VCSCommit(Long.toString(entry.getRevision()), entry.getMessage(),
570-
entry.getAuthor());
572+
return svnLogEntryToVCSCommit(entry);
571573
}
572574
return null;
573575
} catch (SVNException e) {
@@ -688,8 +690,7 @@ public VCSTag getLastTag() {
688690
tagName = name.replace("/" + TAGS_PATH, "") ;
689691
}
690692

691-
return new VCSTag(tagName, entry.getMessage(), entry.getAuthor(), new VCSCommit(Long.toString(copyFromEntry.getRevision()),
692-
copyFromEntry.getMessage(), copyFromEntry.getAuthor()));
693+
return new VCSTag(tagName, entry.getMessage(), entry.getAuthor(), svnLogEntryToVCSCommit(copyFromEntry));
693694
} catch (SVNException e) {
694695
throw new EVCSException(e);
695696
} catch (Exception e) {

src/test/java/org/scm4j/vcs/svn/SVNVCSTest.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void testExceptionThrowing(Exception testException, Method m, Object[] p
158158
doThrow(testException).when(svn).getBranchFirstCommit(null);
159159
doThrow(testException).when(svn).revToSVNEntry(anyString(), any(Long.class));
160160
try {
161-
m.invoke(vcs, params);
161+
m.invoke(vcs, params);
162162
if (wasMockedMethodInvoked()) {
163163
fail();
164164
}
@@ -325,20 +325,6 @@ public void testAddTrunkIfExistsExceptions() throws Exception {
325325
}
326326
}
327327

328-
@Test
329-
public void testGetCommitMessagesExceptions() throws Exception {
330-
SVNRepository mockedRepo = spy(svn.getSVNRepository());
331-
svn.setSVNRepository(mockedRepo);
332-
doThrow(testSVNException).when(mockedRepo).log(any(String[].class), anyLong(), anyLong(), anyBoolean(), anyBoolean(),
333-
any(Integer.class), any(ISVNLogEntryHandler.class));
334-
try {
335-
vcs.getCommitMessages(null, 0);
336-
fail();
337-
} catch (EVCSException e) {
338-
checkEVCSException(e);
339-
}
340-
}
341-
342328
private void checkEVCSException(EVCSException e) {
343329
assertTrue(e.getCause() instanceof SVNException);
344330
assertTrue(e.getCause().getMessage().contains(testSVNException.getMessage()));

0 commit comments

Comments
 (0)