-
Notifications
You must be signed in to change notification settings - Fork 293
feat: change output if all diff output is suppressed #768
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new change style ("MODIFY_SUPPRESSED") to improve the clarity of diff output when all changes are suppressed. It updates the report generation across various output formats and tests for the new suppressed diff output.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
diff/report.go | Adds a new ChangeStyle for "MODIFY_SUPPRESSED" with a descriptive message in diff and simple reports. Updates JSON and template reports with an empty message. |
diff/diff_test.go | Updates tests to expect the new "MODIFY_SUPPRESSED" message when diffs are suppressed. |
diff/diff.go | Modifies diff suppression logic to assign the "MODIFY_SUPPRESSED" change type when applicable. |
did you test it locally? |
diff/diff.go
Outdated
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, []difflib.DiffRecord{}, "MODIFY_SUPPRESSED") | ||
} else { | ||
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, []difflib.DiffRecord{}, entry.changeType) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so many if
? what can we optimize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well there are 3 cases here, how could you satisfy that with less then 2 if
s?
We rewrite it a bit:
if !containsDiff && entry.changeType == "MODIFY" {
entry.changeType = "MODIFY_SUPPRESSED"
}
if containsDiff {
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, diffs, entry.changeType)
} else {
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, []difflib.DiffRecord{}, entry.changeType)
}
or
if containsDiff {
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, diffs, entry.changeType)
} else {
if entry.changeType == "MODIFY" {
entry.changeType = "MODIFY_SUPPRESSED"
}
filteredReport.addEntry(entry.key, entry.suppressedKinds, entry.kind, entry.context, []difflib.DiffRecord{}, entry.changeType)
}
I did add a unit test. |
this is better. |
or we can use new var? |
bd45ab8
to
8883fb5
Compare
I have changed the code. How about this variant:
|
we can try this. |
@yxxhero I have simplified the code even more using switch/case. Also I fixed the the color to be actually used and chose a color that actually exists in the lib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mumoshu WDYT? |
If a diff exists but is suppressed in the output change the text to make it more clear what is actually happening.