Skip to content

Add diffOnly option to approve command #402

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

Merged

Conversation

markbrockhoff
Copy link
Contributor

Closes: #234

I implemented the --diffOnly option suggested by @techeverri in his comment.
It allows the user to only approve changed images that are inside the difference directory. Therefore it is neccessary to run loki test beforehand.
The option can be used to reduce unneccessary updates of images that might have changed slightly but not enough to fail loki test.

It's even possible to set diffOnly to true inside the configuration to make this the default behaviour. In case the setting in the configuration should be overwritten the cli flag can be used.
Example: loki approve --diffOnly false

As this flag does not change the default behaviour of loki, I hope that it can be merged and released soon to fix the issues described inside #234

@markbrockhoff markbrockhoff changed the title Add diff only option to approve command Add diffOnly option to approve command Jul 7, 2022
@techeverri
Copy link
Collaborator

What do you think? @oblador

@gidztech
Copy link
Contributor

gidztech commented Oct 27, 2022

This option would be really useful, since we have some developers using M1 chips and others on Intel, and there are different visuals being output that don't reach our threshold. loki approve currently adds a ton of unnecessary changes to our PRs. For now, we're able to just use the generated loki update command that loki test provides on test failures, which includes a regex filter of stories. I guess loki approve --diffOnly will produce the same result as this?

We had to remove our custom fileNameFormatter to support this. I see that this is a known issue #317

Update: The generated update command has a restriction that if there are > 10 diffs, it's considered too many and it will just update all snapshots

const tooManyToFilter = stories.length > 10;

It would be good if that was not a restriction or is at least configurable. Otherwise, loki approve --diffOnly is definitely something we need.

@xurion
Copy link

xurion commented Feb 21, 2023

Interested to find out if this can be merged or at least considered. The team I'm on with 15 other engineers face the issue of M1 chips vs. other hardware and it means we keep having to jump through unnecessary tasks to keep things clean.

@Flirre
Copy link

Flirre commented Feb 28, 2023

Is this something that is being considered? This would reduce a lot of the problems my team have had with Loki.
@oblador @techeverri

@josephluck
Copy link

We're running in to this as well. @oblador it'd be awesome to consider merging this improvement

@oblador
Copy link
Owner

oblador commented Jun 5, 2023

Good feature, thanks for the patience on this, I have my notifications muted so it few under my radar.

@oblador oblador merged commit 297fa9f into oblador:master Jun 5, 2023
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.

Approve changes more files than the reported difference
7 participants