From c5e31645a362bb552c826fc81d3b1a32f70b2b39 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Thu, 3 Nov 2011 14:30:10 -0400 Subject: [PATCH 1/2] Attempting to fix git forking in windows --- main/Build.scala | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main/Build.scala b/main/Build.scala index e276c7e14..217dbe813 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -87,10 +87,23 @@ object RetrieveUnit } } def dropFragment(base: URI): URI = if(base.getFragment eq null) base else new URI(base.getScheme, base.getSchemeSpecificPart, null) + + lazy val isWindowsShell = + ((!System.getenv("SHELL").contains("cygwin")) && + (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0)) + def gitClone(base: URI, tempDir: File): Unit = - run("git" :: "clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; + if(isWindowsShell) { + run("cmd" :: "/c" :: "git" :: "clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; + } else { + run("git" :: "clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; + } def gitCheckout(tempDir: File, branch: String): Unit = - run("git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; + if(isWindowsShell) { + run("cmd" :: "/c" :: "git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; + } else { + run("git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; + } def run(command: List[String], cwd: File): Unit = { val result = Process(command, cwd) ! ; From 175f08e1e4c524e986d9ecaa5dacdcca733e73cb Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Mon, 7 Nov 2011 07:33:35 -0500 Subject: [PATCH 2/2] Stefan Zeiger's fixes to not NPE when checking for windows. Additional cleanup to put windows git-run checks in one function. --- main/Build.scala | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/main/Build.scala b/main/Build.scala index 217dbe813..6bb0b7f5a 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -88,22 +88,19 @@ object RetrieveUnit } def dropFragment(base: URI): URI = if(base.getFragment eq null) base else new URI(base.getScheme, base.getSchemeSpecificPart, null) - lazy val isWindowsShell = - ((!System.getenv("SHELL").contains("cygwin")) && - (System.getProperty("os.name").toLowerCase().indexOf("windows") >= 0)) - def gitClone(base: URI, tempDir: File): Unit = - if(isWindowsShell) { - run("cmd" :: "/c" :: "git" :: "clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; - } else { - run("git" :: "clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; - } + git("clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ; def gitCheckout(tempDir: File, branch: String): Unit = - if(isWindowsShell) { - run("cmd" :: "/c" :: "git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; - } else { - run("git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; - } + git("checkout" :: "-q" :: branch :: Nil, tempDir) + def git(args: List[String], cwd: File): Unit = + if(isWindowsShell) run(List("cmd", "/c", "git") ++ args, cwd) + else run("git" +: args, cwd) + lazy val isWindowsShell = { + val ostype = System.getenv("OSTYPE") + val isCygwin = ostype != null && ostype.toLowerCase.contains("cygwin") + val isWindows = System.getProperty("os.name", "").toLowerCase.contains("windows") + isWindows && !isCygwin + } def run(command: List[String], cwd: File): Unit = { val result = Process(command, cwd) ! ;