浏览代码

improved git auto detect on Windows

Nicolas Cannasse 12 年之前
父节点
当前提交
f693bf789f
共有 2 个文件被更改,包括 19 次插入15 次删除
  1. 18 14
      std/tools/haxelib/Main.hx
  2. 1 1
      std/tools/haxelib/haxelib.hxproj

+ 18 - 14
std/tools/haxelib/Main.hx

@@ -832,23 +832,27 @@ class Main {
 	function checkGit() {
 		var gitExists = function()
 			try { command("git", []); return true; } catch (e:Dynamic) return false;
-		if (!gitExists())
-		{
-			var match = ~/(.*)git([\\|\/])cmd$/ ;
-			for (path in Sys.getEnv("PATH").split(";"))
+		if( gitExists() )
+			return;
+		// if we have already msys git/cmd in our PATH
+		var match = ~/(.*)git([\\|\/])cmd$/ ;
+		for (path in Sys.getEnv("PATH").split(";"))	{
+			if (match.match(path.toLowerCase()))
 			{
-				if (match.match(path.toLowerCase()))
-				{
-					var newPath = match.matched(1) + "git" +match.matched(2) + "bin";
-					Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" +newPath);
-				}
-			}
-			if (!gitExists())
-			{
-				print("Could not execute git, please make sure it is installed and available in your PATH.");
-				return;
+				var newPath = match.matched(1) + "git" +match.matched(2) + "bin";
+				Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" +newPath);
 			}
 		}
+		if( gitExists() )
+			return;
+		// look at a few default paths
+		for( path in ["C:\\Program Files (x86)\\Git\\bin","C:\\Progra~1\\Git\\bin"] )
+			if( sys.FileSystem.exists(path) ) {
+				Sys.putEnv("PATH", Sys.getEnv("PATH") + ";" +path);
+				if( gitExists() )
+					return;
+			}
+		print("Could not execute git, please make sure it is installed and available in your PATH.");
 	}
 
 	function git() {

+ 1 - 1
std/tools/haxelib/haxelib.hxproj

@@ -23,7 +23,7 @@
     <option flashStrict="False" />
     <option mainClass="tools.haxelib.Site" />
     <option enabledebug="False" />
-    <option additional="-D haxe3&#xA;--next&#xA;-neko haxelib.n&#xA;-main tools.haxelib.Main&#xA;-cmd nekotools boot haxelib.n" />
+    <option additional="-D haxe3&#xA;--next&#xA;-neko haxelib.n&#xA;-main tools.haxelib.Main&#xA;-cmd nekotools boot haxelib.n&#xA;-D haxe3" />
   </build>
   <!-- haxelib libraries -->
   <haxelib>