Skip to content

Commit

Permalink
feat(compare-command): Allow to ignore environment differences
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jun 8, 2023
1 parent 6ef71c9 commit 1eebd08
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/commands/compare/src/main/kotlin/CompareCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class CompareCommand : OrtCommand(
help = "Ignore time differences."
).flag()

private val ignoreEnvironment by option(
"--ignore-environment", "-e",
help = "Ignore environment differences."
).flag()

override fun run() {
if (fileA == fileB) {
println("The arguments point to the same file.")
Expand All @@ -75,6 +80,10 @@ class CompareCommand : OrtCommand(
if (ignoreTime) {
put("""^(\s+(?:start|end)_time:) "[^"]+"$""", "$1 \"${Instant.EPOCH}\"")
}

if (ignoreEnvironment) {
put("""^(\s{2}environment:)$\n(?:^\s{4,}.+\n?)+$""", "$1\n ort_version: \"deadbeef\"")
}
}

val diff = unifiedDiff(fileA, fileB, replacements)
Expand Down

0 comments on commit 1eebd08

Please sign in to comment.