diff --git a/RepositoryMinerForGit/src/main/java/Test.java b/RepositoryMinerForGit/src/main/java/Test.java index 581c248..792a953 100644 --- a/RepositoryMinerForGit/src/main/java/Test.java +++ b/RepositoryMinerForGit/src/main/java/Test.java @@ -1,4 +1,5 @@ import java.io.File; +import java.nio.file.Path; import java.io.IOException; import java.util.List; @@ -41,7 +42,18 @@ if( git != null ){ //. git clone File project = new File( "./project" ); - git.cloneRepository().setURI( amaryllis_server ).setDirectory( project ).call(); + + String filePath = "./project"; + + // フォルダの存在を確認する + if (project.exists()) { + System.out.println("projectフォルダが存在します"); + delete(filePath); + } else { + System.out.println("projectフォルダが存在しません"); + } + + git.cloneRepository().setURI( acanthus_client ).setDirectory( project ).call(); } PlotWalk revWalk = new PlotWalk(repo); @@ -102,4 +114,18 @@ } + public static void delete(String path) { + File filePath = new File(path); + String[] list = filePath.list(); + for(String file : list) { + File f = new File(path + File.separator + file); + if(f.isDirectory()) { + delete(path + File.separator + file); + }else { + f.delete(); + } + } + filePath.delete(); + } + }