mirror of https://github.com/sbt/sbt.git
Merge pull request #1787 from xuwei-k/git-clone-depth
specify the "--depth" parameter for efficient when git clone
This commit is contained in:
commit
58f90cd078
|
|
@ -67,17 +67,25 @@ object Resolvers {
|
||||||
}
|
}
|
||||||
}.toResolver
|
}.toResolver
|
||||||
|
|
||||||
val git: Resolver = new DistributedVCS {
|
val git: Resolver = (info: ResolveInfo) => {
|
||||||
override val scheme = "git"
|
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) {
|
if (uri.hasFragment) {
|
||||||
run("git", "clone", from, to.getAbsolutePath)
|
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 {
|
abstract class DistributedVCS {
|
||||||
val scheme: String
|
val scheme: String
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue