我正在尝试解析 URL 以获得当前的分支或主干。
public SVNConnector(String s_Url, String login, String password, String project) {
try {
url = SVNURL.parseURIEncoded(s_Url);
ISVNAuthenticationManager authManager = new BasicAuthenticationManager(login, password);
DAVRepositoryFactory.setup();
repository = SVNRepositoryFactory.create(url, null);
repository.setAuthenticationManager(authManager);
this.projectName = project;
latestRevision = repository.getLatestRevision();
} catch (SVNException svne) {
logger.error("Impossible to connect to SVN repository. s_Url: "+s_Url+" login:"+login+" password: "+password, svne);
}
}
我的 URL 类似于http://10.61.128.222/svn/i18ntest/trunk
or http://10.61.128.222/svn/PFT/branches/protoi18n
,我需要一个可以输入此 URL 的方法,它会返回/trunk/
or /branches/protoi18n/
,所以我可以运行它:
public List<OutputElement> retrieveI18nFiles() throws SVNException {
List<OutputElement> outs = new ArrayList<OutputElement>();
String path = url.getPath()+"/core/src/main/resources/fr/gefco/"+projectName+"/i18n/"; // this is not working!
latestRevision = repository.getLatestRevision();
// For some reason, type safety is not insured in SVNKit, even if generics are around for some years, now
Collection<SVNDirEntry> entries = repository.getDir(path, latestRevision, (SVNProperties)null, (Collection<SVNDirEntry>)null);
for (SVNDirEntry entry : entries) {
OutputElement out = new OutputElement();
out.setEntry(entry);
out.setOut(retrieveOutputStream(entry,path));
outs.add(out);
}
return outs;
}
url.getPath()
正在返回/svn/i18ntest/trunk/
,这不是我需要的。当然,我可以解析它以获得我需要的位,但我想首先知道 SVNKit 是否提供任何已经证明的方法来做到这一点。