Skip to content

Commit a0534c9

Browse files
author
Ty
committed
sbt#1178 format and validator
1 parent e300518 commit a0534c9

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ case class RpmSpec(meta: RpmMetadata,
224224
sb append ("Release: %s\n" format meta.release)
225225
sb append ("Summary: %s\n" format meta.summary)
226226

227-
meta.epoch filter(_ >= 0) foreach{ epoch =>
227+
meta.epoch filter (_ >= 0) foreach { epoch =>
228228
sb append ("Epoch: %d\n" format epoch)
229229
}
230230

src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ object RpmPlugin extends AutoPlugin {
106106
validatePackageValidators in Rpm := Seq(
107107
nonEmptyMappings((linuxPackageMappings in Rpm).value.flatMap(_.mappings)),
108108
filesExist((linuxPackageMappings in Rpm).value.flatMap(_.mappings)),
109-
checkMaintainer((maintainer in Rpm).value, asWarning = false)
109+
checkMaintainer((maintainer in Rpm).value, asWarning = false),
110+
epochIsNaturalNumber((rpmEpoch in Rpm).value.getOrElse(0))
110111
),
111112
// override the linux sourceDirectory setting
112113
sourceDirectory in Rpm := sourceDirectory.value,

src/main/scala/com/typesafe/sbt/packager/validation/package.scala

+12
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,16 @@ package object validation {
6363
}
6464
}
6565

66+
def epochIsNaturalNumber(epoch: Int): Validation.Validator = () => {
67+
sys.error(s"Passed: $epoch")
68+
if (epoch < 0) {
69+
ValidationError(
70+
description = s"The Epoch cannot be a negative number (found $epoch)",
71+
howToFix = "Change rpmEpoch to Some(n), where n >= 0"
72+
) :: Nil
73+
} else {
74+
Nil
75+
}
76+
}
77+
6678
}

0 commit comments

Comments
 (0)