Временные ряды #59

Merged
romanov73 merged 10 commits from influx into master 2022-10-06 16:09:37 +04:00
Showing only changes of commit 312d613d7c - Show all commits

View File

@ -192,6 +192,7 @@ public class GitRepositoryService {
private void cloneOrUpdateRepo(String repositoryUrl, String branchName) throws GitAPIException, IOException {
Git git;
org.eclipse.jgit.lib.Repository localRepo;
validateOrClearRepositoryDirectory(getProjectDirectoryFile(repositoryUrl));
if (projectDirExists(getProjectDirectoryFile(repositoryUrl))) {
localRepo = new FileRepository(getProjectGitDirectory(repositoryUrl));
git = new Git(localRepo);
@ -210,6 +211,26 @@ public class GitRepositoryService {
git.close();
}
private void validateOrClearRepositoryDirectory(File projectDirectory) {
if (projectDirectory.exists()) {
try {
Git.open(projectDirectory).status().call();
} catch (Exception e) {
deleteDirectory(projectDirectory);
}
}
}
private boolean deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
deleteDirectory(file);
}
}
return directoryToBeDeleted.delete();
}
private void cloneOrUpdateRepo(String url) throws GitAPIException, IOException {
cloneOrUpdateRepo(url, null);
}