From a51ea7d8db65f682c52f31f850ae411405958601 Mon Sep 17 00:00:00 2001 From: esoe Date: Fri, 11 Nov 2022 17:23:13 +0300 Subject: [PATCH] qq --- .../sourceListener/SourceListener.java | 47 ++++++++++--------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/main/java/ru/molokoin/sourceListener/SourceListener.java b/src/main/java/ru/molokoin/sourceListener/SourceListener.java index e6b3e55..5bf9c3e 100644 --- a/src/main/java/ru/molokoin/sourceListener/SourceListener.java +++ b/src/main/java/ru/molokoin/sourceListener/SourceListener.java @@ -15,19 +15,18 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.eclipse.jgit.api.Git; -import org.eclipse.jgit.api.GitCommand; -import org.eclipse.jgit.events.RepositoryListener; +import org.eclipse.jgit.api.errors.GitAPIException; +import org.eclipse.jgit.api.errors.InvalidRemoteException; +import org.eclipse.jgit.api.errors.TransportException; import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import com.fasterxml.jackson.core.exc.StreamReadException; import com.fasterxml.jackson.databind.DatabindException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.deser.impl.ExternalTypeHandler.Builder; public class SourceListener { public Options opt; - public String optionsPath = "options-office.json"; + public String optionsPath = "options-home.json"; public SourceListener(){ try { opt = readOptions(); @@ -54,22 +53,28 @@ public class SourceListener { */ public boolean isUpdated(){ try { - Repository rep = openJGitCookbookRepository(); - System.out.println(">>" + rep.getIdentifier()); + Repository repo = RepoCrafter.copy(opt.getGitLink(), new File(opt.getGitLocalPath())); + System.out.println(repo.getConfig()); + System.out.println(repo.getIndexFile()); + Git git = new Git(repo); + + //repo.close(); + } catch (InvalidRemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TransportException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (GitAPIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } return true; } - public static Repository openJGitCookbookRepository() throws IOException { - FileRepositoryBuilder builder = new FileRepositoryBuilder(); - return builder - .readEnvironment() // scan environment GIT_* variables - .findGitDir() // scan up the file system tree - .build(); - } /** * Извлечение данных из options.json * @return @@ -116,7 +121,7 @@ public class SourceListener { public void download(){ HttpClient client = HttpClient.newHttpClient(); HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create(opt.getLinkVC())) + .uri(URI.create(opt.getZipLink())) .build(); try { HttpResponse response = client.send(request, @@ -132,12 +137,12 @@ public class SourceListener { public static void main(String[] args) { SourceListener ear = new SourceListener(); - ear.download(); - try { - ear.extract(); - } catch (IOException e) { - System.out.println(e.getMessage()); - } + // try { + // ear.download(); + // ear.extract(); + // } catch (IOException e) { + // System.out.println(e.getMessage()); + // } ear.isUpdated(); } }