specify the "--depth" parameter for efficient when git clone

This commit is contained in:
xuwei-k 2014-12-24 01:28:08 +09:00
parent 1952e25c41
commit ad9e71178a
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