|
4 | 4 | import org.apache.commons.lang3.StringUtils;
|
5 | 5 | import org.scm4j.vcs.api.*;
|
6 | 6 | import org.scm4j.vcs.api.exceptions.EVCSBranchExists;
|
| 7 | +import org.scm4j.vcs.api.exceptions.EVCSBranchNotFound; |
7 | 8 | import org.scm4j.vcs.api.exceptions.EVCSException;
|
8 | 9 | import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
|
9 | 10 | import org.scm4j.vcs.api.exceptions.EVCSTagExists;
|
@@ -43,6 +44,7 @@ public class SVNVCS implements IVCS {
|
43 | 44 | public static final String BRANCHES_PATH = "branches/";
|
44 | 45 | public static final String TAGS_PATH = "tags/";
|
45 | 46 | public static final String SVN_VCS_TYPE_STRING = "svn";
|
| 47 | + |
46 | 48 |
|
47 | 49 | public void setClientManager(SVNClientManager clientManager) {
|
48 | 50 | this.clientManager = clientManager;
|
@@ -245,9 +247,14 @@ public void setProxy(String host, int port, String proxyUser, String proxyPasswo
|
245 | 247 | public String getFileContent(String branchName, String filePath, String revision) {
|
246 | 248 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
247 | 249 | try {
|
| 250 | + if (repository.checkPath(getBranchName(branchName), -1L) == SVNNodeKind.NONE) { |
| 251 | + throw new EVCSBranchNotFound(getRepoUrl(), getBranchName(branchName)); |
| 252 | + } |
248 | 253 | repository.getFile(new File(getBranchName(branchName), filePath).getPath().replace("\\", "/"),
|
249 | 254 | (revision == null || revision.isEmpty()) ? -1 : Long.parseLong(revision), new SVNProperties(), baos);
|
250 | 255 | return baos.toString(StandardCharsets.UTF_8.name());
|
| 256 | + } catch (EVCSBranchNotFound e) { |
| 257 | + throw e; |
251 | 258 | } catch (SVNException e) {
|
252 | 259 | if (e.getErrorMessage().getErrorCode().getCode() == SVN_FILE_NOT_FOUND_ERROR_CODE) {
|
253 | 260 | throw new EVCSFileNotFound(getRepoUrl(), getBranchName(branchName), filePath, revision);
|
|
0 commit comments