2011-12-19 08:43:08 +01:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2011 Sanjin Sehic
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package sbt
|
|
|
|
|
|
|
|
|
|
import java.net.URI
|
|
|
|
|
|
|
|
|
|
class RichURI(uri: URI)
|
|
|
|
|
{
|
Optimize retrieving from git repositories
Instead of cloning from a remote git repository for each branch,
revision or tag separately, the git resolver locally clones only once
the remote git repository and then creates further local clones from
this local copy of the remote repository.
First, optimization, of course, is execution speed, because cloning
local repository is much faster than remote repository. Furthermore,
because git uses hard-linking when a clone of local repository is
created, the second optimization is in space consumption.
For example, if we have one project that uses
https://github.com/harrah/xsbt.git#v0.11.1 and second project that
uses https://github.com/harrah/xsbt.git#v0.11.2, in previous git
resolver implementation it would require two separate clones of the
remote git repository at https://github.com/harrah/xsbt.git. But, the
new git resolver requires only one clone of the remote git repository
and two local clones which take no space because of hard-linking.
2011-12-19 10:43:42 +01:00
|
|
|
def copy(scheme: String = uri.getScheme, userInfo: String = uri.getUserInfo,
|
|
|
|
|
host: String = uri.getHost, port: Int = uri.getPort, path: String = uri.getPath,
|
|
|
|
|
query: String = uri.getQuery, fragment: String = uri.getFragment) =
|
|
|
|
|
new URI(scheme, userInfo, host, port, path, query, fragment)
|
|
|
|
|
|
2011-12-19 08:43:08 +01:00
|
|
|
def hasFragment = uri.getFragment ne null
|
|
|
|
|
|
|
|
|
|
def withoutFragment =
|
|
|
|
|
if (hasFragment)
|
|
|
|
|
new URI(uri.getScheme, uri.getSchemeSpecificPart, null)
|
|
|
|
|
else
|
|
|
|
|
uri
|
2011-12-19 11:25:30 +01:00
|
|
|
|
2012-06-12 09:06:03 +02:00
|
|
|
def hasMarkerScheme = new URI(uri.getRawSchemeSpecificPart).getScheme ne null
|
2011-12-19 11:25:30 +01:00
|
|
|
|
|
|
|
|
def withoutMarkerScheme =
|
|
|
|
|
{
|
|
|
|
|
if (hasMarkerScheme)
|
|
|
|
|
if (hasFragment)
|
2012-06-14 10:28:20 +02:00
|
|
|
new URI(uri.getRawSchemeSpecificPart + "#" + uri.getRawFragment)
|
2011-12-19 11:25:30 +01:00
|
|
|
else
|
2012-06-14 10:28:20 +02:00
|
|
|
new URI(uri.getRawSchemeSpecificPart)
|
2011-12-19 11:25:30 +01:00
|
|
|
else
|
|
|
|
|
uri
|
|
|
|
|
}
|
2011-12-19 08:43:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object RichURI
|
|
|
|
|
{
|
|
|
|
|
implicit def fromURI(uri: URI) = new RichURI(uri)
|
|
|
|
|
}
|