shorten default hash suffix for project ID

This commit is contained in:
Mark Harrah 2011-07-12 23:09:57 -04:00
parent f7cb85d36e
commit 555b1c04a4
2 changed files with 2 additions and 1 deletions

View File

@ -29,7 +29,7 @@ trait Plugin
object Build
{
val default: Build = new Build { override def projectDefinitions(base: File) = defaultProject(base) :: Nil }
def defaultID(base: File): String = "default-" + Hash.halfHashString(base.getAbsolutePath)
def defaultID(base: File): String = "default-" + Hash.trimHashString(base.getAbsolutePath, 6)
def defaultProject(base: File): Project = Project(defaultID(base), base).settings(Keys.organization := "default")
def data[T](in: Seq[Attributed[T]]): Seq[T] = in.map(_.data)

View File

@ -33,6 +33,7 @@ object Hash
array
}
def halve(s: String): String = if(s.length > 3) s.substring(0, s.length / 2) else s
def trimHashString(s: String, i: Int): String = toHex(apply(s)).take(i)
def halfHashString(s: String): String = halve(toHex(apply(s)))
/** Calculates the SHA-1 hash of the given String.*/