@@ -413,36 +413,35 @@ public static boolean isUrlAlreadyOpen(File URL) {
413413
414414 public static void openGit (Repository localRepo , IGitAccessor accessor ) {
415415 Git git = null ;
416- boolean alreadyOpen = false ;
416+ boolean alreadyOpen = false ;
417417 try {
418418 String absolutePath = localRepo .getDirectory ().getAbsolutePath ();
419419 for (String s : open .keySet ()) {
420420 Git g = open .get (s );
421- if (g !=null )
422- if (g .getRepository ().getDirectory ().getAbsolutePath ()
423- .contentEquals (absolutePath )) {
424- git =g ;
425- alreadyOpen =true ;
426- break ;
427- }
421+ if (g != null )
422+ if (g .getRepository ().getDirectory ().getAbsolutePath ().contentEquals (absolutePath )) {
423+ git = g ;
424+ alreadyOpen = true ;
425+ break ;
426+ }
428427 }
429- if (!alreadyOpen ) {
428+ if (!alreadyOpen ) {
430429 git = new Git (localRepo );
431430 open .put (absolutePath , git );
432431 }
433432 if (accessor != null ) {
434433 try {
435434 accessor .run (git );
436435 } catch (Throwable t ) {
437- //new IssueReportingExceptionHandler().except(t);
436+ // new IssueReportingExceptionHandler().except(t);
438437 throw new RuntimeException (t );
439438 }
440439 }
441- if (!alreadyOpen )
440+ if (!alreadyOpen )
442441 gitclose (git );
443442 } catch (Throwable t ) {
444- //new IssueReportingExceptionHandler().except(t);
445- if (!alreadyOpen )
443+ // new IssueReportingExceptionHandler().except(t);
444+ if (!alreadyOpen )
446445 if (git != null ) {
447446 gitclose (git );
448447 }
@@ -459,7 +458,7 @@ private static void gitclose(Git git) {
459458 if (git == null )
460459 return ;
461460 open .remove (git .getRepository ().getDirectory ().getAbsolutePath ());
462- //git.getRepository().close();
461+ // git.getRepository().close();
463462 git .close ();
464463 }
465464
@@ -1765,23 +1764,23 @@ public static String locateGitUrl(File f, Git ref) throws IOException {
17651764 return null ;
17661765 }
17671766
1768- public static void locateGit (File f , IGitAccessor access ) throws IOException {
1767+ public static File locateGitTopLevelDirectory (File f ) throws IOException {
17691768 File gitRepoFile = f ;
17701769 while (gitRepoFile != null ) {
17711770 gitRepoFile = gitRepoFile .getParentFile ();
17721771 if (gitRepoFile != null )
17731772 if (new File (gitRepoFile .getAbsolutePath () + "/.git/config" ).exists ()) {
1774- // com.neuronrobotics.sdk.common.Log.error("Fount git repo for file:
1775- // "+gitRepoFile);
1776- Repository localRepo = new FileRepository (gitRepoFile .getAbsoluteFile () + "/.git" );
1777- openGit (localRepo , access );
1778- return ;
1773+ return gitRepoFile ;
17791774 }
17801775 }
1781-
17821776 throw new RuntimeException ("File " + f + " is not in a git repository" );
17831777 }
17841778
1779+ public static void locateGit (File f , IGitAccessor access ) throws IOException {
1780+ Repository localRepo = new FileRepository (locateGitTopLevelDirectory (f ).getAbsoluteFile () + "/.git" );
1781+ openGit (localRepo , access );
1782+ }
1783+
17851784 public static String getText (URL website ) throws Exception {
17861785
17871786 URLConnection connection = website .openConnection ();
@@ -2090,16 +2089,18 @@ public static List<String> getAllLangauges() {
20902089 }
20912090 return langs ;
20922091 }
2092+
20932093 public static List <String > getAllExtentions () {
20942094 ArrayList <String > langs = new ArrayList <>();
20952095 for (String L : getLangaugesMap ().keySet ()) {
20962096 IScriptingLanguage lang = getLangaugesMap ().get (L );
2097- for (String s : lang .getFileExtenetion ()) {
2097+ for (String s : lang .getFileExtenetion ()) {
20982098 langs .add (s );
20992099 }
21002100 }
21012101 return langs ;
21022102 }
2103+
21032104 public static HashMap <String , IScriptingLanguage > getLangaugesMap () {
21042105 return langauges ;
21052106 }
@@ -2164,7 +2165,7 @@ public static String[] copyGitFile(String sourceGit, String targetGit, String fi
21642165 }
21652166 String [] newFileCode ;
21662167 try {
2167- System .out .println ("Opening " + targetFilename + " from " + targetGit );
2168+ System .out .println ("Opening " + targetFilename + " from " + targetGit );
21682169 newFileCode = ScriptingEngine .codeFromGit (targetGit , targetFilename );
21692170 if (newFileCode == null )
21702171 newFileCode = new String [] { "" };
0 commit comments