Example #1
0
  @Override
  public List<Commit> getHistory(int page, int limit, String until)
      throws AmbiguousObjectException, IOException, NoHeadException, GitAPIException, SVNException {
    // Get the repository
    SVNURL svnURL = SVNURL.fromFile(new File(repoPrefix + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    // path to get log
    String[] paths = {"/"};

    // Determine revisions
    long startRevision = repository.getLatestRevision() - page * limit;
    long endRevision = startRevision - limit;
    if (endRevision < 1) {
      endRevision = 1;
    }

    // No log to return.
    if (startRevision < endRevision) {
      return new ArrayList<>();
    }

    // Get the logs
    List<Commit> result = new ArrayList<>();
    for (Object entry : repository.log(paths, null, startRevision, endRevision, false, false)) {
      result.add(new SvnCommit((SVNLogEntry) entry));
    }

    return result;
  }
Example #2
0
 @Override
 public boolean isEmpty() {
   SVNURL svnURL;
   org.tmatesoft.svn.core.io.SVNRepository repository = null;
   try {
     svnURL = SVNURL.fromFile(getDirectory());
     repository = SVNRepositoryFactory.create(svnURL);
     return repository.getLatestRevision() == 0;
   } catch (SVNException e) {
     throw new RuntimeException(e);
   } finally {
     if (repository != null) {
       repository.closeSession();
     }
   }
 }