Skip to content

Commit

Permalink
Add the ORT version and the creation time to the static HTML report
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian.schuberth@here.com>
  • Loading branch information
sschuberth committed May 9, 2019
1 parent b9d8e68 commit ba0e4cb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Expand Up @@ -411,6 +411,7 @@
</script>
<div id="report-container">
<div class="ort-report-label">Scan Report</div>
<div>Created by <strong>ORT</strong>, the <a href="http://oss-review-toolkit.org/">OSS Review Toolkit</a>, version <REPLACE_ORT_VERSION> on <REPLACE_TIMESTAMP>.</div>
<h2>Index</h2>
<ul>
<li>
Expand Down
11 changes: 8 additions & 3 deletions reporter/src/funTest/kotlin/reporters/StaticHtmlReporterTest.kt
Expand Up @@ -19,10 +19,12 @@

package com.here.ort.reporter.reporters

import com.here.ort.model.Environment
import com.here.ort.model.OrtResult
import com.here.ort.model.config.CopyrightGarbage
import com.here.ort.model.readValue
import com.here.ort.reporter.DefaultResolutionProvider
import com.here.ort.utils.test.patchExpectedResult

import io.kotlintest.shouldBe
import io.kotlintest.specs.WordSpec
Expand All @@ -45,10 +47,13 @@ class StaticHtmlReporterTest : WordSpec() {
}

"successfully export to a static HTML page" {
val actualReport = generateReport(ortResult)
val timeStampPattern = Regex("\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z")
val actualReport = generateReport(ortResult).replace(timeStampPattern, "<REPLACE_TIMESTAMP>")

val expectedReport = File("src/funTest/assets/static-html-reporter-test-expected-output.html")
.readText()
val expectedReport = patchExpectedResult(
File("src/funTest/assets/static-html-reporter-test-expected-output.html"),
"<REPLACE_ORT_VERSION>" to Environment().ortVersion
)

actualReport shouldBe expectedReport
}
Expand Down
13 changes: 13 additions & 0 deletions reporter/src/main/kotlin/reporters/StaticHtmlReporter.kt
Expand Up @@ -19,6 +19,7 @@

package com.here.ort.reporter.reporters

import com.here.ort.model.Environment
import com.here.ort.model.OrtResult
import com.here.ort.model.Project
import com.here.ort.model.Severity
Expand All @@ -34,6 +35,7 @@ import com.here.ort.utils.isValidUrl
import com.here.ort.utils.normalizeLineBreaks

import java.io.OutputStream
import java.time.Instant

import javax.xml.parsers.DocumentBuilderFactory

Expand Down Expand Up @@ -98,6 +100,17 @@ class StaticHtmlReporter : Reporter() {
+"Scan Report"
}

div {
+"Created by "
strong { +"ORT" }
+", the "
a {
href = "http://oss-review-toolkit.org/"
+"OSS Review Toolkit"
}
+", version ${Environment().ortVersion} on ${Instant.now()}."
}

if (reportTableModel.metadata.isNotEmpty()) {
metadataTable(reportTableModel.metadata)
}
Expand Down

0 comments on commit ba0e4cb

Please sign in to comment.