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

cmd: removes hidden dependency on diff command #6452

Merged

Conversation

colinjlacy
Copy link
Contributor

Why the changes in this PR are needed?

There's a hidden dependency on the diff command, which can fail if there is no diff tool installed.

What are the changes in this PR?

  • Replaces the call to diff with a call to the go-diff library, which is already installed
  • Adds tests to the modified formatFile function to improve coverage

Further comments:

I wanted to add more tests to continue to improve coverage, specifically for the -w flag, but that's beyond the scope of this issue and would have taken some lengthy digging into the util/test package. Is there a general coverage improvement issue that can be used for things like that?

Fixes #6284

Replaces call to local diff command as a hidden dependency
with call to go-diff, which is already included in the repo.

Fixes open-policy-agent#6284

Signed-off-by: Colin Lacy <colinjlacy@gmail.com>
Signed-off-by: Colin Lacy <colinjlacy@gmail.com>
Copy link
Contributor

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Thank you

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@anderseknert anderseknert merged commit 2f43132 into open-policy-agent:main Dec 4, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opa fmt --diff fails unless external diff tool is present
3 participants