forked from jotu/gabbler
-
Notifications
You must be signed in to change notification settings - Fork 1
/
verify
executable file
·30 lines (24 loc) · 839 Bytes
/
verify
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
exec scala "$0" "$@"
!#
import scala.io.Source
import scala.sys.process._
implicit class ArrayOps[A](args: Array[A]) {
def get(n: Int): Option[A] = if (args isDefinedAt n) Some(args(n)) else None
}
val branch = args get 0 getOrElse sys.error("Missing argument for branch!")
val takeCount = args get 1 map (_.toInt) getOrElse Int.MaxValue
s"git checkout $branch".!!
val commitIds =
(Source fromString "git log --oneline".!!).getLines.toVector collect {
case line if !(line contains "verify:ignore") => line take 7
}
val verify =
(Process("sbt clean") /: (commitIds.init take takeCount).reverse)((process, commitId) =>
process #&& s"git checkout $commitId" #&& "sbt clean test"
)
if (verify.! == 0) {
s"git checkout $branch".!!
println("Successfully verified.")
} else
println("Verification failed!")