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;
}
Aggregations