Search in sources :

Example 1 with ISVNDirEntryHandler

use of org.tmatesoft.svn.core.ISVNDirEntryHandler in project Corgi by kevinYin.

the class CreateDeploymentController method fetchSvnTags.

private List<Map<String, Object>> fetchSvnTags(String svnAddr, ProjectModule module) {
    List<Map<String, Object>> list = new ArrayList<>();
    try {
        SVNURL url = SVNURL.parseURIEncoded(svnAddr);
        final String prePath = (svnAddr.contains("/") ? svnAddr.substring(svnAddr.lastIndexOf("/")) : "");
        DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
        SVNClientManager clientManager = SVNClientManager.newInstance(options, module.getSvnAccount(), module.getSvnPassword());
        SVNLogClient client = clientManager.getLogClient();
        client.doList(url, SVNRevision.HEAD, SVNRevision.HEAD, false, false, new ISVNDirEntryHandler() {

            @Override
            public void handleDirEntry(SVNDirEntry dirEntry) throws SVNException {
                if (StringUtils.isNotEmpty(dirEntry.getRelativePath())) {
                    Map<String, Object> row = Maps.newHashMapWithExpectedSize(2);
                    row.put("url", prePath + "/" + dirEntry.getRelativePath());
                    row.put("version", dirEntry.getRevision());
                    list.add(row);
                }
            }
        });
        if (list.size() > 0) {
            // 倒序排列
            sortBranchInfo(list);
        }
    } catch (SVNException e) {
        logger.error("读取SVN地址失败: " + svnAddr, e);
    }
    return list;
}
Also used : SVNDirEntry(org.tmatesoft.svn.core.SVNDirEntry) ISVNDirEntryHandler(org.tmatesoft.svn.core.ISVNDirEntryHandler) SVNURL(org.tmatesoft.svn.core.SVNURL) DefaultSVNOptions(org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions) SVNException(org.tmatesoft.svn.core.SVNException)

Aggregations

ISVNDirEntryHandler (org.tmatesoft.svn.core.ISVNDirEntryHandler)1 SVNDirEntry (org.tmatesoft.svn.core.SVNDirEntry)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNURL (org.tmatesoft.svn.core.SVNURL)1 DefaultSVNOptions (org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions)1