Skip to content

Commit a5c6961

Browse files
committed
devide getFileContent(): from branch and from revision #2
1 parent 1d263df commit a5c6961

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,18 @@ protected PasswordAuthentication getPasswordAuthentication() {
277277
public String getRepoUrl() {
278278
return repo.getRepoUrl();
279279
}
280-
280+
281281
@Override
282-
public String getFileContent(String branchName, String fileRelativePath, String revision) {
282+
public String getFileContentFromBranch(String branchName, String filePath) throws EVCSFileNotFound {
283+
return getFileContent(branchName, filePath, null);
284+
}
285+
286+
@Override
287+
public String getFileContentFromRevision(String revision, String filePath) throws EVCSFileNotFound {
288+
return getFileContent(null, filePath, revision);
289+
}
290+
291+
private String getFileContent(String branchName, String fileRelativePath, String revision) {
283292
try (IVCSLockedWorkingCopy wc = repo.getVCSLockedWorkingCopy();
284293
Git git = getLocalGit(wc);
285294
Repository gitRepo = git.getRepository();
@@ -309,7 +318,7 @@ public String getFileContent(String branchName, String fileRelativePath, String
309318
treeWalk.setRecursive(true);
310319
treeWalk.setFilter(PathFilter.create(fileRelativePath));
311320
if (!treeWalk.next()) {
312-
throw new EVCSFileNotFound(getRepoUrl(), getRealBranchName(branchName), fileRelativePath, revision);
321+
throw new EVCSFileNotFound(getRepoUrl(), fileRelativePath, revisionCommitId.getName());
313322
}
314323
ObjectId objectId = treeWalk.getObjectId(0);
315324

0 commit comments

Comments
 (0)