Skip to content

Commit

Permalink
strip snapshot suffix safely (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-passiv authored and muuki88 committed Jul 9, 2017
1 parent e0238b8 commit b2586c6
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ object RpmPlugin extends AutoPlugin {
packageArchitecture in Rpm := "noarch",
rpmMetadata := RpmMetadata(
(packageName in Rpm).value,
if (isSnapshot.value) stripSnapshot((version in Rpm).value) else (version in Rpm).value,
(version in Rpm).value.stripSuffix("-SNAPSHOT"),
rpmRelease.value,
rpmPrefix.value,
(packageArchitecture in Rpm).value,
Expand Down Expand Up @@ -163,11 +163,6 @@ object RpmPlugin extends AutoPlugin {
}
}
)

def stripSnapshot(version: String): String = {
val suffixPosition = version.indexOf("-SNAPSHOT")
version.slice(0, suffixPosition)
}
}

object RpmDeployPlugin extends AutoPlugin {
Expand Down
26 changes: 26 additions & 0 deletions src/sbt-test/rpm/snapshot-override-rpm/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
enablePlugins(RpmPlugin)

name := "rpm-test"

version := "0.1.0-SNAPSHOT"

maintainer := "Keir Lawson <keirlawson@gmail.com>"

packageSummary := "Snapshot test rpm package"

packageDescription := """A fun package description of our software,
with multiple lines."""

rpmVendor := "typesafe"

rpmUrl := Some("http://github.com/sbt/sbt-native-packager")

rpmLicense := Some("BSD")

version in Rpm := "1"

TaskKey[Unit]("check-snapshot") := {
assert(rpmRelease.value == "SNAPSHOT", s"RPM has incorrect value ${rpmRelease.value}")
assert(rpmMetadata.value.version == "1", s"RPM has incorrect value ${rpmMetadata.value.version}")
assert((version in Rpm).value == "1", s"RPM has incorrect value ${(version in Rpm).value}")
}
1 change: 1 addition & 0 deletions src/sbt-test/rpm/snapshot-override-rpm/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Test configuration file!
6 changes: 6 additions & 0 deletions src/sbt-test/rpm/snapshot-override-rpm/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Run the debian packaging.
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-1-SNAPSHOT.noarch.rpm

#Check release and version configured correctly
> check-snapshot

0 comments on commit b2586c6

Please sign in to comment.