Skip to content

Show a diff when a file will be or gets modified #1385

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

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from

Conversation

jgelens
Copy link
Contributor

@jgelens jgelens commented Jun 27, 2025

Now shows a diff of files which will be modified, only when its checksum its different.

Thanks @xvello (#985 (comment)) for the code!

This solves #985

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)

@jgelens
Copy link
Contributor Author

jgelens commented Jun 27, 2025

Example output:

Screenshot 2025-06-27 at 09 27 10

@jgelens jgelens marked this pull request as draft July 3, 2025 13:35
@jgelens
Copy link
Contributor Author

jgelens commented Jul 3, 2025

Working on some improvements to not use `host.get_file'

@jgelens jgelens force-pushed the file-diff branch 2 times, most recently from c4d16c8 to 4844468 Compare July 4, 2025 07:31
@jgelens jgelens marked this pull request as ready for review July 4, 2025 09:16
@Fizzadar
Copy link
Member

Fizzadar commented Jul 9, 2025

This is awesome, just noting I'm not forgetting it. Need to handle when to show/not show the diff (ie when -v). Going to get the pending stuff released and get then think on that to land this.

@jgelens
Copy link
Contributor Author

jgelens commented Jul 9, 2025

Right, maybe it would be best to add a new flag for that. I always would like to see the diff, even when not using -v. So maybe we could add a --diff flag for this; similar to the same Ansible feature.

I was also thinking to add a global flag which can also per operation, in case people do not want to show it for e.g. editing a file with passwords.

@xvello
Copy link
Contributor

xvello commented Jul 9, 2025

I also think it's good to show the diffs without verbose logging, that's how I currently use it. A command line switch could indeed be enough.

@jgelens thanks for pushing this over the finish line. When you're pushing other changes, would you mind adding a Co-authored-by: Xavier Vello <xavier.vello@gmail.com> line in the git commit message of the first commit, for attribution?

@jgelens
Copy link
Contributor Author

jgelens commented Jul 9, 2025

@jgelens thanks for pushing this over the finish line. When you're pushing other changes, would you mind adding a Co-authored-by: Xavier Vello <xavier.vello@gmail.com> line in the git commit message of the first commit, for attribution?

Of course, added.

@Fizzadar
Copy link
Member

Fizzadar commented Jul 9, 2025

Right, maybe it would be best to add a new flag for that. I always would like to see the diff, even when not using -v. So maybe we could add a --diff flag for this; similar to the same Ansible feature.

👍 for --diff, good call.

Co-authored-by: Xavier Vello <xavier.vello@gmail.com>
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.

3 participants