我用于我的小型项目 Java SVNKit(用于标记):
目前及其工作:
public void copy(String branchName, String dstTag, boolean isMove, String msg) throws SVNException, IOException {
String finalURL = getSvnUrl() + "tags/" + dstTag;
URL url = new URL(finalURL);
String loginPassword = getUsername() + ":" + getPassword();
String encoded = EncodingUtil.getAsciiString(Base64.encodeBase64(EncodingUtil.getAsciiBytes(loginPassword)));
URLConnection conn = url.openConnection();
conn.setRequestProperty("Authorization", "Basic " + encoded);
HttpURLConnection urlConnect = null;
try {
urlConnect = (HttpURLConnection)conn;
if (urlConnect.getResponseCode() != HttpURLConnection.HTTP_OK) {
ourClientManager.getCopyClient().doCopy(SVNURL.parseURIDecoded(getSvnUrl() + branchName),
SVNRevision.HEAD, SVNURL.parseURIDecoded(finalURL), isMove, msg);
LOGGER.info("svn-tagging " + dstTag);
} else
LOGGER.info(dstTag + " Tag exists.");
} finally {
if (urlConnect != null) {
urlConnect.disconnect();
}
}
}
我想检查标签是否存在,我想用SVNRepository
andSVNClientManager
和 not做/使用HttpURLConnection.HTTP_OK
,有人知道吗?