Skip to content

Commit

Permalink
Add requirement that markdown cannot be generated with empty changes
Browse files Browse the repository at this point in the history
version: 0.7.0
tag: Added
  • Loading branch information
zumhagen committed Jun 30, 2017
1 parent 99ecb7c commit 54e406b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ before_install:
- openssl aes-256-cbc -pass pass:$ENCRYPTION_PASSWORD -in credentials.sbt.enc -out local.credentials.sbt -d
script:
- sbt clean coverage test coverageReport coverageAggregate
after_success:
- sbt coveralls
- sbt clean compile
- sbt "+ publish-signed"
- sbt "+ sonatypeRelease"
env:
Expand Down
4 changes: 1 addition & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name := "sct"

organization := "com.github.bzumhagen"

version := "0.6.0"
version := "0.7.0"

scalaVersion := "2.12.1"

Expand Down Expand Up @@ -31,8 +31,6 @@ def betterFiles(scalaVersion: String) = scalaVersion match {
case _ => "com.github.pathikrit" %% "better-files" % "2.17.0"
}

coverageEnabled := true

pgpSecretRing := file("local.secring.asc")

pgpPublicRing := file("local.pubring.asc")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class GitChangelog(val config: ChangelogConfiguration, val gitDir: File) extends
}

override def generateMarkdown(file: File, changes: Seq[ChangelogChange]): File = {
require(changes.nonEmpty, "Cannot generate markdown without changes")

val engine = new TemplateEngine
val changeBindings = buildChangeBindings(changes)
val nameBinding = Map("name" -> config.name)
Expand Down Expand Up @@ -72,8 +74,7 @@ class GitChangelog(val config: ChangelogConfiguration, val gitDir: File) extends
case _ => None
}

private def buildChangeBindings(
changes: Seq[ChangelogChange]): Map[String, Any] =
private def buildChangeBindings(changes: Seq[ChangelogChange]): Map[String, Any] =
if (config.smartGrouping) {
val latestVersion = changes.maxBy(_.version).version
val latestPatchChanges = changes.filter { change =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,13 @@ class GitChangelogTest extends FlatSpec with Matchers {
val actualChanges = gitChangelog.getChanges
gitChangelog.generateMarkdown(changelogFile, actualChanges).contentAsString shouldBe expectedMarkdown
}

it should "fail if no changes are provided to markdown generation" in {
val gitChangelog = new GitChangelog(DefaultConfiguration, File.newTemporaryDirectory())
val changelogFile = File.newTemporaryFile("changelogTestFile")

assertThrows[IllegalArgumentException] {
gitChangelog.generateMarkdown(changelogFile, Seq())
}
}
}

0 comments on commit 54e406b

Please sign in to comment.