Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CommitSha.scala « github « savage « getbootstrap « com « scala « main « src - github.com/twbs/savage.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e77deb4fd4af219dced0f981cbeb5553aedb02ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.getbootstrap.savage.github

object CommitSha {
  private val ShaRegex = "^[0-9a-f]{40}$".r
  def apply(sha: String): Option[CommitSha] = {
    sha match {
      case ShaRegex(_*) => Some(new CommitSha(sha))
      case _ => None
    }
  }
  def unapply(sha: String): Option[CommitSha] = CommitSha(sha)
}

class CommitSha private(val sha: String) extends AnyVal {
  override def toString = s"CommitSha(${sha})"
}