Beispiel #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;
  }
Beispiel #2
0
  @Override
  public Commit getCommit(String revNumber) throws IOException, SVNException {
    long rev = Integer.parseInt(revNumber);
    String[] paths = {"/"};
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    org.tmatesoft.svn.core.io.SVNRepository repository = SVNRepositoryFactory.create(svnURL);

    for (Object entry : repository.log(paths, null, rev, rev, false, false)) {
      return new SvnCommit((SVNLogEntry) entry);
    }

    return null;
  }
Beispiel #3
0
  @Override
  public String getPatch(String commitId) throws SVNException {
    // Prepare required arguments.
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));
    long rev = Integer.parseInt(commitId);

    // Get diffClient.
    SVNClientManager clientManager = SVNClientManager.newInstance();
    SVNDiffClient diffClient = clientManager.getDiffClient();

    // Using diffClient, write the changes by commitId into
    // byteArrayOutputStream, as unified format.
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    diffClient.doDiff(
        svnURL,
        null,
        SVNRevision.create(rev - 1),
        SVNRevision.create(rev),
        SVNDepth.INFINITY,
        true,
        byteArrayOutputStream);

    return byteArrayOutputStream.toString();
  }
Beispiel #4
0
  private org.tmatesoft.svn.core.io.SVNRepository getSVNRepository() throws SVNException {
    SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName));

    return SVNRepositoryFactory.create(svnURL);
  }