Skip to content

Commit 3d79649

Browse files
committed
EVCSBranchNotFound throwing added at getFileContent()
1 parent 35f1a0a commit 3d79649

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/org/scm4j/vcs/svn/SVNVCS.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.apache.commons.lang3.StringUtils;
55
import org.scm4j.vcs.api.*;
66
import org.scm4j.vcs.api.exceptions.EVCSBranchExists;
7+
import org.scm4j.vcs.api.exceptions.EVCSBranchNotFound;
78
import org.scm4j.vcs.api.exceptions.EVCSException;
89
import org.scm4j.vcs.api.exceptions.EVCSFileNotFound;
910
import org.scm4j.vcs.api.exceptions.EVCSTagExists;
@@ -43,6 +44,7 @@ public class SVNVCS implements IVCS {
4344
public static final String BRANCHES_PATH = "branches/";
4445
public static final String TAGS_PATH = "tags/";
4546
public static final String SVN_VCS_TYPE_STRING = "svn";
47+
4648

4749
public void setClientManager(SVNClientManager clientManager) {
4850
this.clientManager = clientManager;
@@ -245,9 +247,14 @@ public void setProxy(String host, int port, String proxyUser, String proxyPasswo
245247
public String getFileContent(String branchName, String filePath, String revision) {
246248
ByteArrayOutputStream baos = new ByteArrayOutputStream();
247249
try {
250+
if (repository.checkPath(getBranchName(branchName), -1L) == SVNNodeKind.NONE) {
251+
throw new EVCSBranchNotFound(getRepoUrl(), getBranchName(branchName));
252+
}
248253
repository.getFile(new File(getBranchName(branchName), filePath).getPath().replace("\\", "/"),
249254
(revision == null || revision.isEmpty()) ? -1 : Long.parseLong(revision), new SVNProperties(), baos);
250255
return baos.toString(StandardCharsets.UTF_8.name());
256+
} catch (EVCSBranchNotFound e) {
257+
throw e;
251258
} catch (SVNException e) {
252259
if (e.getErrorMessage().getErrorCode().getCode() == SVN_FILE_NOT_FOUND_ERROR_CODE) {
253260
throw new EVCSFileNotFound(getRepoUrl(), getBranchName(branchName), filePath, revision);

0 commit comments

Comments
 (0)