From 972acc871abdd7fcad617a360a6e42196ba1bb3a Mon Sep 17 00:00:00 2001 From: Sanjin Sehic Date: Mon, 19 Dec 2011 11:25:30 +0100 Subject: [PATCH] Allow retrieving of non-standard git URIs Non-standard git URIs are ones that do not start with 'git:' nor end with '.git'. An example of non-standard git URI is 'ssh://server/home/user/repo'. The mechanism for specifying a non-standard git URI is done by prefixing the whole URI with 'git:' to signify that it should be handled with the git resolver. For example, non-standard git URIs like 'git:ssh://server/user/repo' and 'git:https://server/user/repo' can now be used. --- main/Build.scala | 4 +++- main/Resolvers.scala | 2 +- util/io/RichURI.scala | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/main/Build.scala b/main/Build.scala index cc2cc32da..44f53c8bf 100644 --- a/main/Build.scala +++ b/main/Build.scala @@ -57,7 +57,9 @@ object RetrieveUnit object Path { - def unapply(uri: URI) = Option(uri.getPath) + import RichURI.fromURI + + def unapply(uri: URI) = Option(uri.withoutMarkerScheme.getPath) } } object EvaluateConfigurations diff --git a/main/Resolvers.scala b/main/Resolvers.scala index 0e7d49e42..063a1a288 100644 --- a/main/Resolvers.scala +++ b/main/Resolvers.scala @@ -63,7 +63,7 @@ object Resolvers } } - val uri = info.uri + val uri = info.uri.withoutMarkerScheme val staging = info.staging Some { () => diff --git a/util/io/RichURI.scala b/util/io/RichURI.scala index 1cd4cab48..94e4de29c 100644 --- a/util/io/RichURI.scala +++ b/util/io/RichURI.scala @@ -20,6 +20,19 @@ class RichURI(uri: URI) new URI(uri.getScheme, uri.getSchemeSpecificPart, null) else uri + + def hasMarkerScheme = new URI(uri.getSchemeSpecificPart).getScheme ne null + + def withoutMarkerScheme = + { + if (hasMarkerScheme) + if (hasFragment) + new URI(uri.getSchemeSpecificPart + "#" + uri.getFragment) + else + new URI(uri.getSchemeSpecificPart) + else + uri + } } object RichURI