Skip to content

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 also can be used to override single operations. 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.

@jgelens jgelens force-pushed the file-diff branch 2 times, most recently from be64dff to 190c760 Compare July 9, 2025 14:20
@goetzk
Copy link
Contributor

goetzk commented Jul 9, 2025

I've been waiting on this PR, really excited to see it so close to inclusion :) Thanks heaps to everyone involved!

@Fizzadar
Copy link
Member

@jgelens are you happy for me to finish this up with the --diff arg?

@jgelens
Copy link
Contributor Author

jgelens commented Jul 23, 2025

Yeah sure, no problem. Otherwise I can do it next week or so.

@jgelens
Copy link
Contributor Author

jgelens commented Aug 1, 2025

@Fizzadar I'm not sure if adding it to the Config object is enough. See 2381ab9

@jgelens
Copy link
Contributor Author

jgelens commented Aug 25, 2025

@Fizzadar I'm not sure if adding it to the Config object is enough. See 2381ab9

Can you confirm whether this is the right way to implemented flag like this?

@Fizzadar
Copy link
Member

@jgelens sorry for the delay - I think this is correct, thank you!

It's made me think we should (not now) move the -v flags over from state -> config to match, and also that --diff should probably set -v=1 if not set as well (to show the "blah is already installed" etc).

Copy link
Member

@Fizzadar Fizzadar left a comment

Choose a reason for hiding this comment

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

Awesome stuff, @jgelens, very excited to land this!

@Fizzadar Fizzadar merged commit cc58a74 into pyinfra-dev:3.x Aug 28, 2025
53 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.

4 participants