Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare command #7104

Merged
merged 5 commits into from
Jun 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(compare-command): Allow to ignore environment differences
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jun 8, 2023
commit 1eebd08b767a98ca60c08ad2265f290968ab6e7a
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
Loading