Skip to content

Commit

Permalink
Use last path component of a URI in the staged path.
Browse files Browse the repository at this point in the history
  • Loading branch information
harrah committed Jun 23, 2013
1 parent 1a3ea6f commit 6f0028e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion main/src/main/scala/sbt/Resolvers.scala
Expand Up @@ -148,6 +148,19 @@ object Resolvers

def uniqueSubdirectoryFor(uri: URI, in: File) = {
in.mkdirs()
new File(in, Hash.halfHashString(uri.normalize.toASCIIString))
val base = new File(in, Hash.halfHashString(uri.normalize.toASCIIString))
val last = shortName(uri) match { case Some(n) => normalizeDirectoryName(n); case None => "root" }
new File(base, last)
}

private[this] def shortName(uri: URI): Option[String] =
Option(uri.withoutMarkerScheme.getPath).flatMap {
_.split("/").map(_.trim).filterNot(_.isEmpty).lastOption
}

private[this] def normalizeDirectoryName(name: String): String =
StringUtilities.normalize(dropExtensions(name))

private[this] def dropExtensions(name: String): String = name.takeWhile(_ != '.')

}

0 comments on commit 6f0028e

Please sign in to comment.