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

Branch.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: ff52be3f97823b223711c6c8d756ecaf73388ad8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.getbootstrap.savage.github

object Branch {
  private val SafeBranchRegex = "^[0-9a-zA-Z_-]+$".r
  def apply(branchName: String): Option[Branch] = {
    branchName match {
      case SafeBranchRegex(_*) => Some(new Branch(branchName))
      case _ => None
    }
  }
  def unapply(branch: Branch): Option[String] = Some(branch.name)
}

class Branch private(val name: String) extends AnyVal {
  override def toString: String = s"Branch(${name})"
  def asRef = s"refs/heads/${name}"
}