Merge pull request #1787 from xuwei-k/git-clone-depth

specify the "--depth" parameter for efficient when git clone
This commit is contained in:
eugene yokota 2015-02-02 10:46:35 -05:00
commit 58f90cd078
1 changed files with 17 additions and 9 deletions

View File

@ -67,17 +67,25 @@ object Resolvers {
}
}.toResolver
val git: Resolver = new DistributedVCS {
override val scheme = "git"
val git: Resolver = (info: ResolveInfo) => {
val uri = info.uri.withoutMarkerScheme
val localCopy = uniqueSubdirectoryFor(uri.copy(scheme = "git"), in = info.staging)
val from = uri.withoutFragment.toASCIIString
override def clone(from: String, to: File) {
run("git", "clone", from, to.getAbsolutePath)
if (uri.hasFragment) {
val branch = uri.getFragment
Some { () =>
creates(localCopy) {
run("git", "clone", from, localCopy.getAbsolutePath)
run(Some(localCopy), "git", "checkout", "-q", branch)
}
}
} else Some { () =>
creates(localCopy) {
run("git", "clone", "--depth", "1", from, localCopy.getAbsolutePath)
}
}
override def checkout(branch: String, in: File) {
run(Some(in), "git", "checkout", "-q", branch)
}
}.toResolver
}
abstract class DistributedVCS {
val scheme: String