Skip to content

Commit

Permalink
Only write the file if it is different than the current one
Browse files Browse the repository at this point in the history
  • Loading branch information
BraisGabin committed Jan 4, 2022
1 parent aaa9ef0 commit 321e265
Showing 1 changed file with 5 additions and 5 deletions.
Expand Up @@ -19,13 +19,13 @@ class BaselineFacade {

fun createOrUpdate(baselineFile: Path, findings: List<Finding>) {
val ids = findings.map { it.baselineId }.toSortedSet()
val exists = baselineExists(baselineFile)
val baseline = if (exists) {
Baseline.load(baselineFile).copy(currentIssues = ids)
val oldBaseline = if (baselineExists(baselineFile)) {
Baseline.load(baselineFile)
} else {
Baseline(emptySet(), ids)
Baseline(emptySet(), emptySet())
}
if (baseline.isNotEmpty() || exists) {
val baseline = oldBaseline.copy(currentIssues = ids)
if (oldBaseline != baseline) {
baselineFile.parent?.let { Files.createDirectories(it) }
BaselineFormat().write(baseline, baselineFile)
}
Expand Down

0 comments on commit 321e265

Please sign in to comment.