|
|
|
@ -15,19 +15,18 @@ import java.util.zip.ZipEntry;
@@ -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 {
@@ -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 {
@@ -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<Path> response = client.send(request, |
|
|
|
@ -132,12 +137,12 @@ public class SourceListener {
@@ -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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|