Skip to content

Commit f763ec7

Browse files
committed
EVCSBranchNotFound.java added
EVCSBranchNotFound throwing added in getFileContent
1 parent 5d339dc commit f763ec7

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.scm4j.vcs;
2+
3+
import org.scm4j.vcs.api.exceptions.EVCSException;
4+
5+
public class EVCSBranchNotFound extends EVCSException {
6+
7+
private static final long serialVersionUID = 1L;
8+
9+
public EVCSBranchNotFound(String repoUrl, String branchName) {
10+
super(String.format("branch %s is not found in repo %s", branchName, repoUrl));
11+
}
12+
13+
}

src/main/java/org/scm4j/vcs/GitVCS.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,11 @@ public String getFileContent(String branchName, String fileRelativePath, String
298298
.setCredentialsProvider(credentials)
299299
.call();
300300
git.pull().call(); //TODO: add test when we receive correct file version if we change it from another LWC
301-
302301
ObjectId revisionCommitId = gitRepo.resolve(revision == null ? "refs/heads/" + getRealBranchName(branchName) : revision);
302+
if (revision == null && revisionCommitId == null) {
303+
throw new EVCSBranchNotFound(getRepoUrl(), getRealBranchName(branchName));
304+
}
305+
303306
RevCommit commit = revWalk.parseCommit(revisionCommitId);
304307
RevTree tree = commit.getTree();
305308
treeWalk.addTree(tree);

0 commit comments

Comments
 (0)