Merge pull request #77 from simono/fix-gitRetrieve

Recover when gitRetrieve(.) fails.
This commit is contained in:
Mark Harrah 2011-06-27 08:06:32 -07:00
commit fa1dd84e5b
1 changed files with 9 additions and 4 deletions

View File

@ -56,9 +56,14 @@ object RetrieveUnit
def gitRetrieve(base: URI, tempDir: File): Unit =
if(!tempDir.exists)
{
IO.createDirectory(tempDir)
gitClone(dropFragment(base), tempDir)
Option(base.getFragment) foreach { branch => gitCheckout(tempDir, branch) }
try {
IO.createDirectory(tempDir)
gitClone(dropFragment(base), tempDir)
Option(base.getFragment) foreach { branch => gitCheckout(tempDir, branch) }
} catch {
case e => IO.delete(tempDir)
throw e
}
}
def dropFragment(base: URI): URI = if(base.getFragment eq null) base else new URI(base.getScheme, base.getSchemeSpecificPart, null)
def gitClone(base: URI, tempDir: File): Unit =
@ -246,4 +251,4 @@ object BuildPaths
final val ConfigDirectoryName = ".sbt"
def crossPath(base: File, instance: ScalaInstance): File = base / ("scala_" + instance.version)
}
}