Stefan Zeiger's fixes to not NPE when checking for windows. Additional cleanup to put windows git-run checks in one function.

This commit is contained in:
Josh Suereth 2011-11-07 07:33:35 -05:00
parent c5e31645a3
commit 175f08e1e4
1 changed files with 11 additions and 14 deletions

View File

@ -88,21 +88,18 @@ object RetrieveUnit
} }
def dropFragment(base: URI): URI = if(base.getFragment eq null) base else new URI(base.getScheme, base.getSchemeSpecificPart, null) 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 = def gitClone(base: URI, tempDir: File): Unit =
if(isWindowsShell) { git("clone" :: dropFragment(base).toASCIIString :: tempDir.getAbsolutePath :: Nil, tempDir) ;
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 = def gitCheckout(tempDir: File, branch: String): Unit =
if(isWindowsShell) { git("checkout" :: "-q" :: branch :: Nil, tempDir)
run("cmd" :: "/c" :: "git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; def git(args: List[String], cwd: File): Unit =
} else { if(isWindowsShell) run(List("cmd", "/c", "git") ++ args, cwd)
run("git" :: "checkout" :: "-q" :: branch :: Nil, tempDir) ; 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 = def run(command: List[String], cwd: File): Unit =
{ {