Skip to content

Commit 76da3f2

Browse files
committed
another workaround for faulty git checkouts
1 parent c6d4da3 commit 76da3f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/commonwl/view/git/GitService.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.eclipse.jgit.api.errors.CheckoutConflictException;
3636
import org.eclipse.jgit.api.errors.GitAPIException;
3737
import org.eclipse.jgit.api.errors.RefNotFoundException;
38+
import org.eclipse.jgit.errors.RepositoryNotFoundException;
3839
import org.eclipse.jgit.lib.ObjectId;
3940
import org.eclipse.jgit.lib.PersonIdent;
4041
import org.eclipse.jgit.revwalk.RevCommit;
@@ -81,8 +82,12 @@ public Git getRepository(GitDetails gitDetails, boolean reuseDir)
8182
// Check if folder already exists
8283
Path repoDir = gitStorage.resolve(baseName);
8384
if (Files.isReadable(repoDir) && Files.isDirectory(repoDir)) {
84-
repo = Git.open(repoDir.toFile());
85-
repo.fetch().call();
85+
try {
86+
repo = Git.open(repoDir.toFile());
87+
repo.fetch().call();
88+
} catch (RepositoryNotFoundException ex) {
89+
repo = cloneRepo(gitDetails.getRepoUrl(), repoDir.toFile());
90+
}
8691
} else {
8792
// Create a folder and clone repository into it
8893
Files.createDirectory(repoDir);

0 commit comments

Comments
 (0)