1 package com.neuronrobotics.bowlerstudio.scripting;
3 import com.neuronrobotics.bowlerstudio.IssueReportingExceptionHandler;
4 import com.neuronrobotics.bowlerstudio.util.FileChangeWatcher;
5 import com.neuronrobotics.sdk.common.Log;
6 import com.neuronrobotics.sdk.util.ThreadUtil;
7 import com.neuronrobotics.video.OSUtil;
9 import eu.mihosoft.vrl.v3d.parametrics.CSGDatabase;
10 import org.apache.commons.io.FileUtils;
11 import org.apache.commons.io.IOUtils;
12 import org.eclipse.jgit.api.CloneCommand;
13 import org.eclipse.jgit.api.CreateBranchCommand;
14 import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
15 import org.eclipse.jgit.api.Git;
16 import org.eclipse.jgit.api.ListBranchCommand.ListMode;
17 import org.eclipse.jgit.api.PullCommand;
18 import org.eclipse.jgit.api.Status;
19 import org.eclipse.jgit.api.TransportConfigCallback;
20 import org.eclipse.jgit.api.errors.AbortedByHookException;
21 import org.eclipse.jgit.api.errors.CanceledException;
22 import org.eclipse.jgit.api.errors.CheckoutConflictException;
23 import org.eclipse.jgit.api.errors.ConcurrentRefUpdateException;
24 import org.eclipse.jgit.api.errors.DetachedHeadException;
25 import org.eclipse.jgit.api.errors.GitAPIException;
26 import org.eclipse.jgit.api.errors.InvalidConfigurationException;
27 import org.eclipse.jgit.api.errors.InvalidRefNameException;
28 import org.eclipse.jgit.api.errors.InvalidRemoteException;
29 import org.eclipse.jgit.api.errors.NoHeadException;
30 import org.eclipse.jgit.api.errors.NoMessageException;
31 import org.eclipse.jgit.api.errors.RefAlreadyExistsException;
32 import org.eclipse.jgit.api.errors.RefNotAdvertisedException;
33 import org.eclipse.jgit.api.errors.RefNotFoundException;
34 import org.eclipse.jgit.api.errors.TransportException;
35 import org.eclipse.jgit.api.errors.UnmergedPathsException;
36 import org.eclipse.jgit.api.errors.WrongRepositoryStateException;
37 import org.eclipse.jgit.internal.storage.file.FileRepository;
38 import org.eclipse.jgit.lib.Config;
39 import org.eclipse.jgit.lib.Constants;
40 import org.eclipse.jgit.lib.ProgressMonitor;
41 import org.eclipse.jgit.lib.Ref;
42 import org.eclipse.jgit.lib.Repository;
43 import org.eclipse.jgit.revwalk.RevCommit;
44 import org.eclipse.jgit.transport.RefSpec;
45 import org.jsoup.Jsoup;
46 import org.jsoup.nodes.Attributes;
47 import org.jsoup.nodes.Document;
48 import org.jsoup.nodes.Element;
49 import org.jsoup.select.Elements;
50 import org.kohsuke.github.GHCreateRepositoryBuilder;
51 import org.kohsuke.github.GHGist;
52 import org.kohsuke.github.GHRepository;
53 import org.kohsuke.github.GitHub;
54 import java.io.BufferedReader;
56 import java.io.IOException;
57 import java.io.InputStreamReader;
58 import java.io.OutputStream;
59 import java.io.StringWriter;
61 import java.net.URLConnection;
62 import java.nio.charset.StandardCharsets;
63 import java.nio.file.Files;
64 import java.nio.file.Paths;
65 import java.text.DecimalFormat;
66 import java.util.ArrayList;
67 import java.util.Collection;
68 import java.util.Collections;
69 import java.util.Comparator;
70 import java.util.Date;
71 import java.util.HashMap;
72 import java.util.Iterator;
73 import java.util.List;
75 import java.util.Scanner;
78 import javax.swing.filechooser.FileSystemView;
79 import javax.xml.transform.Transformer;
80 import javax.xml.transform.TransformerConfigurationException;
81 import javax.xml.transform.TransformerException;
82 import javax.xml.transform.TransformerFactory;
83 import javax.xml.transform.dom.DOMSource;
84 import javax.xml.transform.stream.StreamResult;
94 private static final ArrayList<GitLogProgressMonitor>
logListeners =
new ArrayList<>();
98 private static final String[]
imports =
new String[] {
99 "java.nio.file",
"java.util",
"java.awt.image",
"javafx.scene.text",
"javafx.scene",
"javafx.scene.control",
100 "eu.mihosoft.vrl.v3d",
"eu.mihosoft.vrl.v3d.svg",
"eu.mihosoft.vrl.v3d.samples",
101 "eu.mihosoft.vrl.v3d.parametrics",
"com.neuronrobotics.imageprovider",
102 "com.neuronrobotics.sdk.addons.kinematics.xml",
"com.neuronrobotics.sdk.addons.kinematics",
103 "com.neuronrobotics.sdk.dyio.peripherals",
"com.neuronrobotics.sdk.dyio",
"com.neuronrobotics.sdk.common",
104 "com.neuronrobotics.sdk.ui",
"com.neuronrobotics.sdk.util",
"com.neuronrobotics.sdk.serial",
105 "com.neuronrobotics.sdk.addons.kinematics",
"com.neuronrobotics.sdk.addons.kinematics.math",
106 "com.neuronrobotics.sdk.addons.kinematics.gui",
"com.neuronrobotics.sdk.config",
107 "com.neuronrobotics.bowlerkernel",
"com.neuronrobotics.bowlerstudio",
108 "com.neuronrobotics.bowlerstudio.scripting",
"com.neuronrobotics.bowlerstudio.tabs",
109 "com.neuronrobotics.bowlerstudio.physics",
"com.neuronrobotics.bowlerstudio.physics",
110 "com.neuronrobotics.bowlerstudio.vitamins",
"com.neuronrobotics.bowlerstudio.creature",
111 "com.neuronrobotics.bowlerstudio.threed" };
113 private static HashMap<String, File>
filesRun =
new HashMap<>();
124 private static ArrayList<IGithubLoginListener>
loginListeners =
new ArrayList<IGithubLoginListener>();
126 private static HashMap<String, IScriptingLanguage>
langauges =
new HashMap<>();
130 static HashMap<Git, GitTimeoutThread> gitOpenTimeout =
new HashMap<>();
149 System.err.println(
"Workspace: " +
workspace.getAbsolutePath());
153 appdata =
new File(file.getAbsolutePath() +
"/appdata");
157 File oldpass =
new File(System.getProperty(
"user.home") +
"/.github");
158 if (oldpass.exists())
162 }
catch (Exception e) {
164 throw new RuntimeException(e);
186 throws InvalidRemoteException, TransportException, GitAPIException {
187 CloneCommand setURI = Git.cloneRepository().setURI(remoteURI);
190 setURI.setDirectory(dir);
198 Git git = setURI.call();
215 throws InvalidRemoteException, TransportException, GitAPIException {
216 boolean startsWith = remoteURI.startsWith(
"git@");
220 }
catch (org.eclipse.jgit.api.errors.JGitInternalException ex) {
221 if (ex.getMessage().contains(
"already exists and is not an empty directory")) {
226 }
catch (org.eclipse.jgit.api.errors.TransportException ex) {
227 if (ex.getMessage().contains(
"Auth fail") && !startsWith) {
237 RuntimeException e =
new RuntimeException();
238 return new ProgressMonitor() {
242 String stage =
"done";
243 long timeofLastUpdate = 0;
246 public void update(
int completed) {
247 for (Iterator<Git> iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) {
248 Git g = iterator.next();
250 if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) {
257 DecimalFormat df =
new DecimalFormat(
"###.#");
258 String format = df.format(total > 0 ? ((sum) / total * 100) : 0);
259 if (!format.contains(
"."))
260 format = format +
".0";
261 while (format.length() < 5) {
262 format =
" " + format;
264 String str = format +
"% " + stage +
" " + reponame +
" " + tasks +
" of task " + type;
265 if (timeofLastUpdate + 500 < System.currentTimeMillis()) {
266 System.out.println(str);
267 timeofLastUpdate = System.currentTimeMillis();
277 public void start(
int totalTasks) {
282 public boolean isCancelled() {
287 public void endTask() {
288 String
string =
"100% " + stage +
" " + reponame +
" " + type;
289 System.out.println(
string);
291 l.onUpdate(
string, e);
296 public void beginTask(String title,
int totalWork) {
302 timeofLastUpdate = 0;
314 Repository localRepo;
318 }
catch (IOException e) {
322 throw new RuntimeException(
"IOException making repo");
328 for (Iterator<Git> iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) {
329 Git g = iterator.next();
331 if (t.ref.toLowerCase().contentEquals(URL.toLowerCase())) {
346 public static Git
openGit(Repository localRepo) {
348 for (Iterator<Git> iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) {
349 Git g = iterator.next();
350 if (g.getRepository().getDirectory().getAbsolutePath()
351 .contentEquals(localRepo.getDirectory().getAbsolutePath())) {
354 while (gitOpenTimeout.containsKey(g)) {
357 "Git is locked by other process, blocking " + localRepo.getDirectory().getAbsolutePath());
358 System.out.println(
"Git locked " + t.ref);
361 System.out.println(
"Blocking process: ");
363 new Exception().printStackTrace(System.out);
372 Git git =
new Git(localRepo);
386 if (gitOpenTimeout.containsKey(git)) {
387 Thread thread = gitOpenTimeout.remove(git);
388 if (thread !=
null) {
392 new RuntimeException(
"Closing a git object that was not opened with a timeout!"));
395 git.getRepository().close();
442 public static Object
inlineScriptRun(File code, ArrayList<Object> args, String shellTypeStorage)
throws Exception {
443 if (
filesRun.get(code.getName()) ==
null) {
448 if (
langauges.get(shellTypeStorage) !=
null) {
449 return langauges.get(shellTypeStorage).inlineScriptRun(code, args);
464 if (
langauges.get(shellTypeStorage) !=
null) {
465 return langauges.get(shellTypeStorage).inlineScriptRun(line, args);
488 String relative = FileSystemView.getFileSystemView().getDefaultDirectory().getPath();
490 if (OSUtil.isOSX() || OSUtil.isLinux())
491 if (!relative.endsWith(
"Documents")) {
492 relative = relative +
"/Documents";
494 if (OSUtil.isWindows()) {
495 if (!relative.endsWith(
"Documents")) {
496 relative = relative +
"\\Documents";
500 File file =
new File(relative +
"/bowler-workspace/");
509 if (l.isSupportedFileExtenetion(name))
510 return l.getShellType();
516 public static void login() throws IOException {
526 public static void logout() throws IOException {
541 if (in.endsWith(
".git")) {
542 in = in.substring(0, in.lastIndexOf(
'.'));
544 String domain = in.split(
"//")[1];
545 String[] tokens = domain.split(
"/");
546 if (tokens[0].toLowerCase().contains(
"gist.github.com") && tokens.length >= 2) {
548 String
id = tokens[2].split(
"#")[0];
549 Log.
debug(
"Gist URL Detected " +
id);
551 }
catch (ArrayIndexOutOfBoundsException e) {
553 String
id = tokens[1].split(
"#")[0];
554 Log.
debug(
"Gist URL Detected " +
id);
556 }
catch (ArrayIndexOutOfBoundsException ex) {
557 throw new RuntimeException(e);
567 ArrayList<String> ret =
new ArrayList<>();
568 Document doc = Jsoup.parse(html);
569 Elements links = doc.select(
"script");
570 for (
int i = 0; i < links.size(); i++) {
571 Element e = links.get(i);
573 Attributes n = e.attributes();
574 String jSSource = n.get(
"src");
575 if (jSSource.contains(
"https://gist.github.com/")) {
577 String slug = jSSource;
578 String js = slug.split(
".js")[0];
579 String[]
id = js.split(
"/");
580 ret.add(
id[
id.length - 1]);
587 if (!javafx.scene.web.WebEngine.class.isInstance(engine))
588 throw new RuntimeException(
"Engine must be of type javafx.scene.web.WebEngine");
595 TransformerFactory tf = TransformerFactory.newInstance();
596 Transformer t = tf.newTransformer();
597 StringWriter sw =
new StringWriter();
598 t.transform(
new DOMSource(((javafx.scene.web.WebEngine) engine).getDocument()),
new StreamResult(sw));
599 html = sw.getBuffer().toString();
601 }
catch (TransformerConfigurationException e) {
602 throw new RuntimeException(e);
603 }
catch (TransformerException e) {
604 throw new RuntimeException(e);
608 ArrayList<String> ret =
new ArrayList<>();
616 public static void waitForLogin() throws IOException, InvalidRemoteException, TransportException, GitAPIException {
618 System.err.println(
"No network, cant log in");
626 System.err.println(
"No login ID found!");
630 System.err.println(
"No login api key found!");
633 System.err.println(
"Performing Login");
637 System.err.println(
"\nERROR: Wrong Password!\n");
641 }
catch (Exception e) {
642 throw new RuntimeException(e);
650 for (Iterator<Git> iterator = gitOpenTimeout.keySet().iterator(); iterator.hasNext();) {
651 Git g = iterator.next();
653 if (t.ref.toLowerCase().contentEquals(remoteURI.toLowerCase())) {
655 System.err.println(
"\n\n\nPaused " + reason +
" by another thread, waiting for repo " + remoteURI);
656 new Exception().printStackTrace(System.err);
657 System.err.println(
"Paused by:");
659 System.err.println(
"\n\n\n");
667 if (remoteURI ==
null)
669 if (remoteURI.length() < 4)
673 new Exception(
"\n\nDelete " + remoteURI +
"called Here\n").printStackTrace(System.out);
684 if (!folder.exists() || !folder.isDirectory())
686 File[] files = folder.listFiles();
688 for (File f : files) {
689 if (f.isDirectory()) {
695 System.out.println(
"Deleting File " + f.getAbsolutePath());
697 System.err.println(
"File failed to delete! " + f);
699 }
catch (Throwable t) {
707 System.out.println(
"Deleting Folder " + folder.getAbsolutePath());
709 }
catch (Throwable t) {
712 if (folder.exists()) {
713 System.err.println(
"Folder failed to delete! " + folder);
719 private static void loadFilesToList(ArrayList<String> f, File directory, String extnetion) {
723 private static void loadFilesToList(ArrayList<String> f, File directory, String extnetion, Git ref) {
724 if (directory ==
null)
726 for (
final File fileEntry : directory.listFiles()) {
728 if (fileEntry.getName().endsWith(
".git") || fileEntry.getName().startsWith(
".git"))
730 if (extnetion !=
null)
731 if (extnetion.length() > 0)
732 if (!fileEntry.getName().endsWith(extnetion))
735 if (fileEntry.isDirectory()) {
740 if (l.isSupportedFileExtenetion(fileEntry.getName())) {
750 public static ArrayList<String>
filesInGit(String remote, String branch, String extnetion)
throws Exception {
751 return filesInGit(remote, branch, extnetion,
null);
754 public static ArrayList<String>
filesInGit(String remote, String branch, String extnetion, Git ref)
756 ArrayList<String> f =
new ArrayList<>();
759 File gistDir =
cloneRepo(remote, branch);
766 public static ArrayList<String>
filesInGit(String remote)
throws Exception {
770 public static ArrayList<String>
filesInGit(String remote, Git ref)
throws Exception {
781 return gist.getOwner().getLogin();
785 public static File
createFile(String git, String fileName, String commitMessage)
throws Exception {
790 public static void pushCodeToGit(String
id, String branch, String FileName, String content, String commitMessage)
797 File desired =
new File(gistDir.getAbsoluteFile() +
"/" + FileName);
800 pushCodeToGit(
id, branch, FileName, content, commitMessage, flagNewFile);
804 boolean createdFlag =
false;
805 File parent = desired.getParentFile();
806 if (!parent.exists()) {
808 System.err.println(
"Creating " + parent.getAbsolutePath());
810 if (!desired.exists() && parent.exists()) {
811 System.err.println(
"Creating " + desired.getAbsolutePath());
812 desired.createNewFile();
818 public static void commit(String
id, String branch, String FileName, String content, String commitMessage,
819 boolean flagNewFile)
throws Exception {
820 commit(
id, branch, FileName, content, commitMessage, flagNewFile,
null);
823 @SuppressWarnings(
"deprecation")
824 public static
void commit(String
id, String branch, String FileName, String content, String commitMessage,
825 boolean flagNewFile, Git gitRef) throws Exception {
834 File desired =
new File(gistDir.getAbsoluteFile() +
"/" + FileName);
836 String localPath = gistDir.getAbsolutePath();
837 File gitRepoFile =
new File(localPath +
"/.git");
839 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
845 git.add().addFilepattern(FileName).call();
849 if (content !=
null) {
850 OutputStream out =
null;
852 out = FileUtils.openOutputStream(desired,
false);
853 IOUtils.write(content, out);
858 IOUtils.closeQuietly(out);
862 commit(
id, branch, commitMessage, gitRef);
863 }
catch (Exception ex) {
872 if (!desired.getName().contentEquals(
"csgDatabase.json")) {
874 String remoteURI = gitID[0];
877 if (s.contentEquals(
"csgDatabase.json")) {
883 @SuppressWarnings(
"resource")
884 String c =
new Scanner(dbFile).useDelimiter(
"\\Z").next();
889 }
catch (Exception e) {
895 @SuppressWarnings(
"deprecation")
896 public static
void pushCodeToGit(String remoteURI, String branch, String FileName, String content,
897 String commitMessage,
boolean flagNewFile) throws Exception {
899 commit(remoteURI, branch, FileName, content, commitMessage, flagNewFile);
904 File gistDir =
cloneRepo(remoteURI, branch);
905 File desired =
new File(gistDir.getAbsoluteFile() +
"/" + FileName);
908 OutputStream out =
null;
910 out = FileUtils.openOutputStream(desired,
false);
911 IOUtils.write(content, out);
915 IOUtils.closeQuietly(out);
921 String localPath = gistDir.getAbsolutePath();
922 File gitRepoFile =
new File(localPath +
"/.git");
924 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
928 pull(remoteURI, branch);
929 }
catch (java.lang.RuntimeException exp) {
934 git.add().addFilepattern(FileName).call();
936 if (content !=
null) {
937 OutputStream out =
null;
939 out = FileUtils.openOutputStream(desired,
false);
940 IOUtils.write(content, out);
945 IOUtils.closeQuietly(out);
948 if (git.getRepository().getConfig().getString(
"remote",
"origin",
"url").startsWith(
"git@"))
955 System.out.println(
"PUSH OK! file: " + desired +
" on branch " +
getBranch(remoteURI));
956 }
catch (Exception ex) {
957 ex.printStackTrace();
960 String
id = gitID[0];
967 public static String[]
codeFromGit(String
id, String FileName)
throws Exception {
970 if (targetFile.exists()) {
974 String text =
new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())),
975 StandardCharsets.UTF_8);
976 return new String[] { text, FileName, targetFile.getAbsolutePath() };
982 private static String[]
codeFromGistID(String
id, String FileName)
throws Exception {
983 String giturl =
"https://gist.github.com/" +
id +
".git";
986 if (targetFile.exists()) {
987 System.err.println(
"Gist at GIT : " + giturl);
989 String text =
new String(Files.readAllBytes(Paths.get(targetFile.getAbsolutePath())),
990 StandardCharsets.UTF_8);
991 return new String[] { text, FileName, targetFile.getAbsolutePath() };
1002 public static Object
inlineGistScriptRun(String gistID, String Filename, ArrayList<Object> args)
throws Exception {
1007 public static Object
gitScriptRun(String gitURL, String Filename)
throws Exception {
1011 public static Object
gitScriptRun(String gitURL, String Filename, ArrayList<Object> args)
throws Exception {
1012 String[] gistData =
codeFromGit(gitURL, Filename);
1017 throws InvalidRemoteException, TransportException, GitAPIException, IOException {
1024 public static File
fileFromGit(String remoteURI, String branch, String fileInRepo)
1025 throws InvalidRemoteException, TransportException, GitAPIException, IOException {
1026 File gitRepoFile =
cloneRepo(remoteURI, branch);
1027 return new File(gitRepoFile.getAbsolutePath() +
"/" + fileInRepo);
1032 String[] colinSplit = remoteURI.split(
":");
1034 String gitSplit = colinSplit[1].substring(0, colinSplit[1].lastIndexOf(
'.'));
1035 File gistDir =
new File(
getWorkspace().getAbsolutePath() +
"/gitcache/" + gitSplit +
"/.git");
1037 }
catch (ArrayIndexOutOfBoundsException ex) {
1038 System.err.println(
"Failed to parse " + remoteURI);
1045 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1046 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1048 File gitRepoFile =
uriToFile(remoteURI);
1049 if (!gitRepoFile.exists()) {
1050 gitRepoFile =
cloneRepo(remoteURI,
null);
1053 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1054 String branch = localRepo.getBranch();
1057 throw new RuntimeException(
"FAULT! " + remoteURI +
" has no branch!");
1062 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1063 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1065 File gitRepoFile =
uriToFile(remoteURI);
1066 if (!gitRepoFile.exists()) {
1067 gitRepoFile =
cloneRepo(remoteURI,
null);
1070 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1071 String branch = localRepo.getFullBranch();
1074 throw new RuntimeException(
"FAULT! " + remoteURI +
" has no branch!");
1079 public static void deleteBranch(String remoteURI, String toDelete)
throws Exception {
1081 boolean found =
false;
1083 if (s.contains(toDelete)) {
1088 throw new RuntimeException(toDelete +
" can not be deleted because it does not exist");
1090 File gitRepoFile =
uriToFile(remoteURI);
1091 if (!gitRepoFile.exists()) {
1092 gitRepoFile =
cloneRepo(remoteURI,
null);
1095 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1103 if (!toDelete.contains(
"heads")) {
1104 toDelete =
"heads/" + toDelete;
1106 if (!toDelete.contains(
"refs")) {
1107 toDelete =
"refs/" + toDelete;
1109 Exception ex =
null;
1112 git.branchDelete().setBranchNames(toDelete).call();
1115 RefSpec refSpec =
new RefSpec().setSource(
null).setDestination(toDelete);
1116 git.push().setRefSpecs(refSpec).setRemote(
"origin")
1119 }
catch (Exception e) {
1128 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1129 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1135 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1136 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1154 }
catch (Exception e) {
1155 e.printStackTrace();
1163 source = git.log().setMaxCount(1).call().iterator().next();
1165 }
catch (NoHeadException ex) {
1168 }
catch (Throwable ex) {
1178 throws GitAPIException, RefNotFoundException, InvalidRefNameException, CheckoutConflictException,
1179 InvalidRemoteException, TransportException, IOException {
1181 CreateBranchCommand setName = git.branchCreate().setName(
newBranch);
1183 setName = setName.setStartPoint(source);
1185 Ref ref = git.getRepository().findRef(Constants.HEAD);
1186 setName = setName.setStartPoint(ref.getName());
1187 setName.setForce(
true);
1190 System.out.println(
"Created new branch " + remoteURI +
"\t\t" +
newBranch);
1191 }
catch (org.eclipse.jgit.api.errors.RefNotFoundException ex) {
1192 System.err.println(
"ERROR Creating " +
newBranch +
" in " + remoteURI);
1193 ex.printStackTrace();
1194 }
catch (org.eclipse.jgit.api.errors.RefAlreadyExistsException ex) {
1197 git.checkout().setName(
newBranch).call();
1199 git.push().setRemote(remoteURI).setRefSpecs(
new RefSpec(
newBranch +
":" +
newBranch))
1204 @SuppressWarnings(
"deprecation")
1206 Repository repo = git.getRepository();
1207 Config storedConfig = repo.getConfig();
1208 Set<String> uriList = repo.getConfig().getSubsections(
"remote");
1209 String remoteURI =
null;
1210 for (String remoteName : uriList) {
1211 if (remoteURI ==
null)
1212 remoteURI = storedConfig.getString(
"remote", remoteName,
"url");
1215 long startTime = System.currentTimeMillis();
1216 while (System.currentTimeMillis() < (startTime + 2000)) {
1217 for (Ref ref : repo.getAllRefs().values()) {
1218 if (ref.getObjectId() !=
null) {
1220 if (branchList.size() > 0) {
1234 File gitRepoFile =
uriToFile(remoteURI);
1235 if (!gitRepoFile.exists()) {
1236 gitRepoFile =
cloneRepo(remoteURI,
null);
1240 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1249 public static List<Ref>
listBranches(String remoteURI, Git git)
throws Exception {
1254 List<Ref> list = git.branchList().setListMode(ListMode.ALL).call();
1261 File gitRepoFile =
uriToFile(remoteURI);
1262 if (!gitRepoFile.exists()) {
1263 gitRepoFile =
cloneRepo(remoteURI,
null);
1266 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1270 List<Ref> list = git.branchList().call();
1273 }
catch (Exception ex) {
1277 return new ArrayList<>();
1281 ArrayList<String> branchNames =
new ArrayList<>();
1284 for (Ref ref : list) {
1287 branchNames.add(ref.getName());
1293 ArrayList<String> branchNames =
new ArrayList<>();
1296 for (Ref ref : list) {
1299 branchNames.add(ref.getName());
1304 public static void pull(String remoteURI, String branch)
throws IOException, CheckoutConflictException,
1305 NoHeadException, InvalidRemoteException, WrongRepositoryStateException {
1311 File gitRepoFile =
uriToFile(remoteURI);
1312 if (!gitRepoFile.exists()) {
1313 gitRepoFile =
cloneRepo(remoteURI, branch);
1316 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile());
1320 String ref = git.getRepository().getConfig().getString(
"remote",
"origin",
"url");
1323 PullCommand command;
1324 if (ref !=
null && ref.startsWith(
"git@")) {
1332 }
catch (org.eclipse.jgit.api.errors.TransportException ex) {
1333 if (ex.getMessage().contains(
"Auth fail")) {
1342 }
catch (CheckoutConflictException ex) {
1349 }
catch (WrongRepositoryStateException e) {
1350 e.printStackTrace();
1355 }
catch (InvalidConfigurationException e) {
1359 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1360 }
catch (DetachedHeadException e) {
1363 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1364 }
catch (InvalidRemoteException e) {
1367 throw new InvalidRemoteException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1368 }
catch (CanceledException e) {
1371 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1372 }
catch (RefNotFoundException e) {
1375 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1376 }
catch (RefNotAdvertisedException e) {
1384 RevCommit source = git.log().setMaxCount(1).call().iterator().next();
1389 }
catch (Exception ex) {
1391 ex.printStackTrace();
1392 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + ex.getMessage());
1394 }
catch (NoHeadException e) {
1407 }
catch (TransportException e) {
1408 e.printStackTrace();
1411 if (git.getRepository().getConfig().getString(
"remote",
"origin",
"url").startsWith(
"git@")) {
1416 }
catch (Exception ex) {
1418 throw new RuntimeException(
1419 "remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1423 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1426 }
catch (GitAPIException e) {
1427 e.printStackTrace();
1430 throw new RuntimeException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1432 }
catch (InvalidRemoteException e) {
1435 throw new InvalidRemoteException(
"remoteURI " + remoteURI +
" branch " + branch +
" " + e.getMessage());
1436 }
catch (Throwable t) {
1442 public static void pull(String remoteURI)
throws IOException, RefAlreadyExistsException, RefNotFoundException,
1443 InvalidRefNameException, InvalidRemoteException, TransportException, GitAPIException {
1450 public static void checkoutCommit(String remoteURI, String branch, String commitHash)
throws IOException {
1453 if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(
".git")) {
1454 System.err.println(
"Invailid git file!" + gitRepoFile.getAbsolutePath());
1455 throw new RuntimeException(
"Invailid git file!" + gitRepoFile.getAbsolutePath());
1457 Repository localRepo =
new FileRepository(gitRepoFile);
1460 git.checkout().setName(commitHash).call();
1461 git.checkout().setCreateBranch(
true).setName(branch).setStartPoint(commitHash).call();
1463 }
catch (Exception ex) {
1464 ex.printStackTrace();
1472 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1473 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1477 public static void checkout(String remoteURI, Ref branch)
1478 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1479 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1480 String[] name = branch.getName().split(
"/");
1481 String myName = name[name.length - 1];
1485 public static void checkout(String remoteURI, String branch)
1486 throws IOException, RefAlreadyExistsException, RefNotFoundException, InvalidRefNameException,
1487 CheckoutConflictException, InvalidRemoteException, TransportException, GitAPIException {
1491 File gitRepoFile =
uriToFile(remoteURI);
1492 if (!gitRepoFile.exists() || !gitRepoFile.getAbsolutePath().endsWith(
".git")) {
1493 System.err.println(
"Invailid git file!" + gitRepoFile.getAbsolutePath());
1494 throw new RuntimeException(
"Invailid git file!" + gitRepoFile.getAbsolutePath());
1498 if (currentBranch !=
null) {
1500 Repository localRepo =
new FileRepository(gitRepoFile);
1502 branch = currentBranch;
1504 if (currentBranch.length() < branch.length() || !currentBranch.endsWith(branch)) {
1505 System.err.println(
"Current branch is " + currentBranch +
" need " + branch);
1511 for (Ref R : branches) {
1512 if (R.getName().endsWith(branch)) {
1513 System.err.println(
"\nFound upstream " + R.getName());
1523 }
catch (org.eclipse.jgit.api.errors.TransportException ex) {
1528 }
catch (RefAlreadyExistsException e) {
1531 throw new RuntimeException(e);
1532 }
catch (RefNotFoundException e) {
1535 throw new RuntimeException(e);
1536 }
catch (InvalidRefNameException e) {
1539 throw new RuntimeException(e);
1540 }
catch (CheckoutConflictException e) {
1542 }
catch (GitAPIException e) {
1545 throw new RuntimeException(e);
1546 }
catch (Exception e) {
1549 throw new RuntimeException(e);
1551 }
catch (Exception ex) {
1554 throw new RuntimeException(ex);
1563 private static void shallowCheckout(String remoteURI, String branch, Git git)
throws GitAPIException,
1564 RefAlreadyExistsException, InvalidRefNameException, RefNotFoundException, CheckoutConflictException {
1566 git.checkout().setName(branch).setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
1567 .setStartPoint(
"origin/" + branch).call();
1569 }
catch (RefNotFoundException e) {
1570 git.branchCreate().setName(branch).setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM)
1571 .setStartPoint(
"origin/" + branch).setForce(
true).call();
1572 git.checkout().setName(branch).setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK)
1573 .setStartPoint(
"origin/" + branch).call();
1575 }
catch (CheckoutConflictException con) {
1581 private static boolean resolveConflict(String remoteURI, CheckoutConflictException con, Git git) {
1586 Status stat = git.status().call();
1587 Set<String> changed = stat.getModified();
1588 if (changed.size() > 0) {
1589 System.out.println(
"Modified ");
1590 for (String p : changed) {
1591 System.out.println(
"Modified Conflict with: " + p);
1593 String content =
"";
1595 bytes = Files.readAllBytes(
fileFromGit(remoteURI, p).toPath());
1596 content =
new String(bytes,
"UTF-8");
1599 "auto-save in ScriptingEngine.resolveConflict",
false, git);
1600 }
catch (Exception e) {
1602 e.printStackTrace();
1604 }
catch (IOException e1) {
1606 e1.printStackTrace();
1612 Set<String> untracked = stat.getUntracked();
1613 if (untracked.size() > 0) {
1614 System.out.println(
"Untracked ");
1615 for (String p : untracked) {
1616 System.out.println(
"Untracked Conflict with: " + p);
1622 }
catch (Exception e) {
1624 e.printStackTrace();
1635 public static File
cloneRepo(String remoteURI, String branch) {
1638 String localPath = gistDir.getAbsolutePath();
1639 File gitRepoFile =
new File(localPath +
"/.git");
1640 File dir =
new File(localPath);
1642 if (!gitRepoFile.exists()) {
1646 System.out.println(
"Cloning files from: " + remoteURI);
1648 System.out.println(
" branch: " + branch);
1649 System.out.println(
" to: " + localPath);
1650 Throwable ex =
null;
1654 if (branch ==
null) {
1667 }
catch (org.eclipse.jgit.api.errors.JGitInternalException exe) {
1671 }
catch (Throwable e) {
1672 e.printStackTrace();
1675 throw new RuntimeException(e);
1679 if (branch !=
null) {
1682 }
catch (Exception e) {
1683 throw new RuntimeException(e);
1696 File gitRepoFile =
new File(f.getAbsolutePath());
1697 while (gitRepoFile !=
null) {
1698 if (
new File(gitRepoFile.getAbsolutePath() +
"/.git/config").exists()) {
1700 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile() +
"/.git");
1704 String url = git.getRepository().getConfig().getString(
"remote",
"origin",
"url");
1705 if (!url.endsWith(
".git"))
1711 gitRepoFile = gitRepoFile.getParentFile();
1718 File gitRepoFile = f;
1719 while (gitRepoFile !=
null) {
1720 gitRepoFile = gitRepoFile.getParentFile();
1721 if (gitRepoFile !=
null)
1722 if (
new File(gitRepoFile.getAbsolutePath() +
"/.git/config").exists()) {
1724 Repository localRepo =
new FileRepository(gitRepoFile.getAbsoluteFile() +
"/.git");
1733 public static String
getText(URL website)
throws Exception {
1735 URLConnection connection = website.openConnection();
1736 BufferedReader in =
new BufferedReader(
new InputStreamReader(connection.getInputStream()));
1738 StringBuilder response =
new StringBuilder();
1741 while ((inputLine = in.readLine()) !=
null)
1742 response.append(inputLine +
"\n");
1746 return response.toString();
1788 @SuppressWarnings(
"unused")
1790 throws InvalidRemoteException, TransportException, GitAPIException, IOException {
1791 return fileFromGit(
"https://gist.github.com/" +
string +
".git", string2);
1797 File dir = git.getRepository().getDirectory().getParentFile();
1799 return dir.toURI().relativize(currentFile.toURI()).getPath();
1802 @SuppressWarnings(
"unused")
1810 }
catch (IOException e) {
1813 throw new RuntimeException(e);
1828 String[] strings =
new String[] { string,
findLocalPath(currentFile, git) };
1832 }
catch (Throwable t) {
1833 t.printStackTrace();
1844 }
catch (IOException e1) {
1846 throw new RuntimeException(e1);
1858 }
catch (Exception e1) {
1865 }
catch (Throwable t) {
1870 }
catch (Throwable t) {
1882 }
catch (Exception e) {
1884 if (git.getRepository().getConfig().getString(
"remote",
"origin",
"url").startsWith(
"git@")) {
1892 }
catch (Exception ex) {
1901 public static GHGist
forkGist(String currentGist)
throws Exception {
1910 return incoming.fork();
1925 public static String
fork(String sourceURL, String newRepoName, String newRepoDescription)
throws Exception {
1926 GHRepository repository;
1930 }
catch (org.kohsuke.github.HttpException ex) {
1931 if (ex.getMessage().contains(
"name already exists on this account")) {
1933 System.out.println(
"Repo exists!");
1934 return repository.getHttpTransportUrl();
1938 String gitRepo = repository.getHttpTransportUrl();
1940 ArrayList<String> files =
filesInGit(sourceURL);
1942 Repository sourceRepoObject = git.getRepository();
1944 sourceRepoObject.getConfig().setString(
"remote",
"origin",
"url", gitRepo);
1945 if (git.getRepository().getConfig().getString(
"remote",
"origin",
"url").startsWith(
"git@"))
1956 }
catch (org.kohsuke.github.HttpException ex) {
1958 if (ex.getMessage().contains(
"name already exists on this account")) {
1960 .getHttpTransportUrl();
1962 ex.printStackTrace();
1963 }
catch (Throwable ex) {
1964 ex.printStackTrace();
1967 throw new RuntimeException(
"Repo could not be forked and does not exist");
1971 throws IOException, org.kohsuke.github.HttpException {
1974 GHCreateRepositoryBuilder builder = github.createRepository(newName);
1975 builder.description(description);
1976 GHRepository repo = builder.create();
1977 for (
int i = 0; i < 5; i++) {
1979 repo = github.getRepositoryById(
"" + repo.getId());
1981 }
catch (Exception ex) {
1982 ex.printStackTrace();
1986 }
catch (InterruptedException e) {
1988 e.printStackTrace();
1992 }
catch (org.kohsuke.github.HttpException ex) {
1997 public static GHRepository
makeNewRepo(String newName, String description)
throws IOException {
1998 if (description.length() < 2) {
1999 description =
new Date().toString();
2002 GHRepository gist =
null;
2005 String url = gist.getHttpTransportUrl();
2009 commit(url,
"main",
"firstCommit");
2011 }
catch (IOException | GitAPIException e) {
2013 e.printStackTrace();
2015 }
catch (org.kohsuke.github.HttpException ex) {
2016 if (ex.getMessage().contains(
"name already exists on this account")) {
2028 Repository repository =
locateGit.getRepository();
2029 String
string = repository.getConfig().getString(
"remote",
"origin",
"url");
2033 }
catch (IOException e) {
2035 e.printStackTrace();
2041 return htmlUrl.toExternalForm();
2046 System.out.println(externalForm);
2051 ArrayList<String> langs =
new ArrayList<>();
2064 if (
langauges.get(L).isSupportedFileExtenetion(extention)) {
2080 public static String[]
copyGitFile(String sourceGit, String targetGit, String filename) {
2081 return copyGitFile(sourceGit, targetGit, filename, filename,
false);
2084 public static String[]
copyGitFile(String sourceGit, String targetGit, String filename, String outFile,
2085 boolean bailIfExisting) {
2086 String targetFilename = outFile;
2087 String[] WalkingEngine;
2088 if (targetGit.contains(
"gist.github.com") && filename.contains(
"/")) {
2089 String[] parts = filename.split(
"/");
2090 targetFilename = parts[parts.length - 1];
2101 }
catch (Exception e) {
2109 }
catch (InvalidRemoteException e) {
2110 throw new RuntimeException(e);
2111 }
catch (TransportException e) {
2112 throw new RuntimeException(e);
2113 }
catch (GitAPIException e) {
2114 throw new RuntimeException(e);
2115 }
catch (IOException e) {
2116 throw new RuntimeException(e);
2117 }
catch (Exception e) {
2118 throw new RuntimeException(e);
2120 String[] newFileCode;
2123 if (newFileCode ==
null)
2124 newFileCode =
new String[] {
"" };
2125 if (newFileCode[0].length() < 10) {
2126 System.out.println(
"Copy Content to " + targetGit +
"/" + targetFilename);
2128 WalkingEngine[0],
"copy file content");
2130 }
catch (Exception e) {
2131 throw new RuntimeException(e);
2133 }
catch (Exception e1) {
2134 throw new RuntimeException(e1);
2137 return new String[] { targetGit, targetFilename };
2140 public static Ref
getBranch(String remoteURI, String branch)
throws IOException, GitAPIException {
2143 for (Ref r : branches) {
2144 if (r.getName().endsWith(branch)) {
2152 public static Collection<Ref>
getAllBranches(String remoteURI)
throws IOException, GitAPIException {
2155 String ref = git.getRepository().getConfig().getString(
"remote",
"origin",
"url");
2158 System.out.print(
"Getting branches " + ref +
" ");
2159 if (ref !=
null && ref.startsWith(
"git@")) {
2160 return Git.lsRemoteRepository().setHeads(
true).setRemote(remoteURI)
2163 return Git.lsRemoteRepository().setHeads(
true).setRemote(remoteURI)
2172 String localPath = gistDir.getAbsolutePath();
2173 File gitRepoFile =
new File(localPath +
"/.git");
2174 return new FileRepository(gitRepoFile.getAbsoluteFile());
2178 if (remoteURI.endsWith(
"/"))
2179 throw new RuntimeException(
"URL needs to end in .git, no trailing slash " + remoteURI);
2180 if (!remoteURI.endsWith(
".git"))
2181 throw new RuntimeException(
"URL needs to end in .git " + remoteURI);
2182 String[] colinSplit = remoteURI.split(
":");
2184 String gitSplit = colinSplit[1].substring(0, colinSplit[1].lastIndexOf(
'.'));
2185 File gistDir =
new File(
getWorkspace().getAbsolutePath() +
"/gitcache/" + gitSplit);
2186 if (!gistDir.exists()) {
2193 throws IOException, GitAPIException {
2197 for (Ref iterableBranchInstance : branches) {
2198 String[] name = iterableBranchInstance.getName().split(
"/");
2199 String myName = name[name.length - 1];
2206 commit(url, branch,
"New branch " + branch +
" created here");
2209 private static void commit(String url, String branch, String message)
2210 throws IOException, GitAPIException, NoHeadException, NoMessageException, UnmergedPathsException,
2211 ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException {
2212 commit(url, branch, message,
null);
2215 private static void commit(String url, String branch, String message, Git passedRef)
2216 throws IOException, GitAPIException, NoHeadException, NoMessageException, UnmergedPathsException,
2217 ConcurrentRefUpdateException, WrongRepositoryStateException, AbortedByHookException {
2218 Git git = passedRef;
2222 git.commit().setAll(
true).setMessage(message).call();
2224 if (arrayList !=
null) {
2225 for (
int i = 0; i < arrayList.size(); i++) {
2226 Runnable r = arrayList.get(i);
2229 }
catch (Throwable t) {
2230 t.printStackTrace();
2234 }
catch (Throwable t) {
2235 if (passedRef ==
null)
2239 if (passedRef ==
null)
2252 int vnum1 = 0, vnum2 = 0;
2255 for (
int i = 0, j = 0; (i < v1.length() || j < v2.length());) {
2258 while (i < v1.length() && v1.charAt(i) !=
'.') {
2259 vnum1 = vnum1 * 10 + (v1.charAt(i) -
'0');
2265 while (j < v2.length() && v2.charAt(j) !=
'.') {
2266 vnum2 = vnum2 * 10 + (v2.charAt(j) -
'0');
2285 ArrayList<String> tags =
new ArrayList<>();
2289 call = jGit.tagList().call();
2290 for (Ref ref : call) {
2291 String
string = ref.getName().split(
"/")[2];
2294 }
catch (Throwable e) {
2296 e.printStackTrace();
2299 Collections.sort(tags,
new Comparator<String>() {
2300 public int compare(String object1, String object2) {
2308 public static boolean tagExists(String remoteURI, String newTag) {
2310 for (String s : tags) {
2311 System.out.println(
"Checking " + newTag +
" against " + s);
2312 if (s.contentEquals(newTag)) {
2319 public static void tagRepo(String remoteURI, String newTag) {
2320 System.out.println(
"Tagging " + remoteURI +
" at " + newTag);
2322 System.out.println(
"ERROR! Tag exists " + remoteURI +
"@" + newTag);
2329 git.tag().setName(newTag).setForceUpdate(
true).call();
2330 }
catch (Throwable t) {
2331 t.printStackTrace();
2333 if (git.getRepository().getConfig().getString(
"remote",
"origin",
"url").startsWith(
"git@"))
2339 }
catch (GitAPIException e) {
2341 e.printStackTrace();
void uncaughtException(Thread t, Throwable e)
RuntimeException getException()
static GitHub setupAnyonmous()
static String getUsername()
static boolean hasNetwork()
static void checkInternet()
static CredentialsProvider getCredentialProvider()
static String getLoginID()
static GitHub getGithub()
static void waitForLogin()
static synchronized void login()
static IGitHubLoginManager getLoginManager()
static void setLoginManager(IGitHubLoginManager lm)
static boolean loggedIn()
static void loadLoginData(File ws)
static String getPassword()
static String[] copyGitFile(String sourceGit, String targetGit, String filename)
static File getLastFile()
static boolean resolveConflict(String remoteURI, CheckoutConflictException con, Git git)
static void pushCodeToGit(String id, String branch, String FileName, String content, String commitMessage)
static final String[] imports
static String[] codeFromGit(String id, String FileName)
static TransportConfigCallback transportConfigCallback
static String[] findGitTagFromFile(File currentFile)
static boolean isAutoupdate()
static void checkoutCommit(String remoteURI, String branch, String commitHash)
static List< String > getCurrentGist(String addr, Object engine)
static ArrayList< IGithubLoginListener > loginListeners
static Object inlineScriptRun(File code, ArrayList< Object > args, String shellTypeStorage)
static File fileFromGistID(String string, String string2)
static void checkout(String remoteURI, String branch)
static File cloneRepo(String remoteURI, String branch)
static Repository getRepository(String remoteURI)
static Git cloneRepoLocalSelectAuth(String remoteURI, File dir, boolean useSSH)
static void checkout(String remoteURI, RevCommit commit)
static File createFile(String git, String fileName, String commitMessage)
static String[] getImports()
static List< String > listBranchNames(String remoteURI)
static void commit(String id, String branch, String FileName, String content, String commitMessage, boolean flagNewFile)
static Ref getBranch(String remoteURI, String branch)
static List< String > returnFirstGist(String html)
static ArrayList< String > filesInGit(String remote, String branch, String extnetion)
static File fileFromGit(String remoteURI, String branch, String fileInRepo)
static String urlToGist(String in)
static void deleteBranch(String remoteURI, String toDelete)
static ArrayList< String > filesInGit(String remote)
static void waitForRepo(String remoteURI, String reason)
static void shallowCheckout(String remoteURI, String branch, Git git)
static Git openGit(Repository localRepo)
static List< String > listLocalBranchNames(String remoteURI)
static GHRepository makeNewRepoNoFailOver(String newName, String description)
static void closeGit(Git git)
static void clearLogListener()
static File getFileEngineRunByName(String filename)
static boolean checkOwner(String url)
static String getUserIdOfGist(String id)
static String fork(String sourceURL, String newRepoName, String newRepoDescription)
static GHRepository makeNewRepo(String newName, String description)
static void removeIGithubLoginListener(IGithubLoginListener l)
static boolean tagExists(String remoteURI, String newTag)
static GitTimeoutThread makeTimeoutThread(Git git)
static List< String > getAllLangauges()
static void waitForLogin()
static String locateGitUrlString(File f)
static List< Ref > listBranches(String remoteURI, Git git)
static boolean isUrlAlreadyOpen(String URL)
static ArrayList< String > filesInGit(String remote, String branch, String extnetion, Git ref)
static void pull(String remoteURI)
static void addLogListener(GitLogProgressMonitor l)
static boolean isLoginSuccess()
static boolean ensureExistance(File desired)
static String locateGitUrl(File f)
static boolean hasNetwork()
static void loadFilesToList(ArrayList< String > f, File directory, String extnetion)
static Git locateGit(File f)
static HashMap< String, IScriptingLanguage > langauges
static Object inlineGistScriptRun(String gistID, String Filename, ArrayList< Object > args)
static void deleteRepo(String remoteURI)
static List< Ref > listBranches(String remoteURI)
static String[] copyGitFile(String sourceGit, String targetGit, String filename, String outFile, boolean bailIfExisting)
static void newBranchLocal(String newBranch, String remoteURI, Git git, RevCommit source)
static String urlToString(URL htmlUrl)
static boolean checkOwner(File currentFile)
static List< Ref > listLocalBranches(String remoteURI)
static HashMap< String, ArrayList< Runnable > > onCommitEventListeners
static Object gitScriptRun(String gitURL, String Filename)
static String getShellType(String name)
static Object gitScriptRun(String gitURL, String Filename, ArrayList< Object > args)
static void deleteFolder(File folder)
static HashMap< String, File > filesRun
static void setLoginManager(IGitHubLoginManager lm)
static boolean setAutoupdate(boolean autoupdate)
static void setWorkspace(File file)
static Object inlineFileScriptRun(File f, ArrayList< Object > args)
static ArrayList< String > filesInGit(String remote, Git ref)
static String findLocalPath(File currentFile, Git git)
static int versionCompare(String v1, String v2)
static Object inlineScriptStringRun(String line, ArrayList< Object > args, String shellTypeStorage)
static void setLastFile(File lastFile)
static void commit(String url, String branch, String message, Git passedRef)
static String locateGitUrl(File f, Git ref)
static IScriptingLanguage getLangaugeByExtention(String extention)
static GHGist forkGist(String currentGist)
static File uriToFile(String remoteURI)
static GitHub setupAnyonmous()
static String newBranch(String remoteURI, String newBranch)
static boolean autoupdate
static String[] codeFromGistID(String id, String FileName)
static void removeOnCommitEventListeners(String url, Runnable event)
static String[] findGitTagFromFile(File currentFile, Git ref)
static void newBranch(String remoteURI, String newBranch, RevCommit source)
static void loadFilesToList(ArrayList< String > f, File directory, String extnetion, Git ref)
static boolean checkOwner(Git git)
static final int TIME_TO_WAIT_BETWEEN_GIT_PULL
static final ArrayList< GitLogProgressMonitor > logListeners
static ProgressMonitor getProgressMoniter(String type, String remoteURI)
static boolean hasAtLeastOneReference(Git git)
static String getFullBranch(String remoteURI)
static HashMap< String, IScriptingLanguage > getLangaugesMap()
static List< String > getAllTags(String gitRepo)
static Git openGit(String url)
static File fileFromGit(String remoteURI, String fileInRepo)
static String getText(URL website)
static File getWorkspace()
static File getRepositoryCloneDirectory(String remoteURI)
static String urlToGist(URL htmlUrl)
static void removeLogListener(GitLogProgressMonitor l)
static void deleteCache()
static Collection< Ref > getAllBranches(String remoteURI)
static void addIGithubLoginListener(IGithubLoginListener l)
static void setCommitContentsAsCurrent(String url, String branch, RevCommit commit)
static void addScriptingLanguage(IScriptingLanguage lang)
static String getBranch(String remoteURI)
static Git cloneRepoLocal(String remoteURI, File dir)
static void addOnCommitEventListeners(String url, Runnable event)
static void commit(String url, String branch, String message)
static void pull(String remoteURI, String branch)
static void tagRepo(String remoteURI, String newTag)
static IGitHubLoginManager getLoginManager()
static void checkout(String remoteURI, Ref branch)
static void close(File fileToWatch)
static void notifyOfDelete(File fileToWatch)
static void debug(String message)
static void wait(int time)
static void setDbFile(File dbFile)
static void saveDatabase()
abstract String getShellType()